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

1.4.1 to be

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-08-24 08:21:56 +00:00
parent a281c99668
commit a1b57d0add
32 changed files with 211 additions and 435 deletions

View file

@ -1,3 +1,21 @@
Sat Aug 21 11:30:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (ADJ): should not adjust addresses to data on heap.
Fri Aug 20 20:50:58 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
* defines.h (PATH_SEP): path separator is ";" for OS/2.
Thu Aug 19 10:50:43 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
* gc.c (rb_gc): add volatile to avoid GCC optimaize bug(?).
Wed Aug 18 23:48:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* due to disk trouble, some change records were lost. several
modification made to eval.c, gc.c, io.c, pack.c,
ext/extmk.rb.in, and lib/mkmf.rb.
Fri Aug 13 15:41:39 1999 Yukihiro Matsumoto <matz@netlab.co.jp> Fri Aug 13 15:41:39 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* stable version 1.4.0 released. * stable version 1.4.0 released.

View file

@ -80,7 +80,6 @@ cygwin/GNUmakefile.in
ext/Setup ext/Setup
ext/Setup.dj ext/Setup.dj
ext/Setup.emx ext/Setup.emx
ext/Setup.nt
ext/Setup.x68 ext/Setup.x68
ext/aix_mksym.rb ext/aix_mksym.rb
ext/mswin32_extmk.rb ext/mswin32_extmk.rb

View file

@ -1,6 +1,6 @@
.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995 .\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
This document explains how to make extention libraries for Ruby. This document explains how to make extension libraries for Ruby.
1. Basic knowledge 1. Basic knowledge
@ -16,7 +16,7 @@ To retrieve an C data from the VALUE, you need to:
(1) Identify VALUE's data type (1) Identify VALUE's data type
(2) Convert VALUE into C data (2) Convert VALUE into C data
Converting to wrong data type may cause serious promblems. Converting to wrong data type may cause serious problems.
1.1 Data-types 1.1 Data-types
@ -24,7 +24,7 @@ Converting to wrong data type may cause serious promblems.
Ruby interpreter has data-types as below: Ruby interpreter has data-types as below:
T_NIL nil T_NIL nil
T_OBJECT ordinaly object T_OBJECT ordinary object
T_CLASS class T_CLASS class
T_MODULE module T_MODULE module
T_FLOAT floating point number T_FLOAT floating point number
@ -32,7 +32,7 @@ Ruby interpreter has data-types as below:
T_REGEXP regular expression T_REGEXP regular expression
T_ARRAY array T_ARRAY array
T_FIXNUM Fixnum(31bit integer) T_FIXNUM Fixnum(31bit integer)
T_HASH assosiative array T_HASH associative array
T_STRUCT (Ruby) structure T_STRUCT (Ruby) structure
T_BIGNUM multi precision integer T_BIGNUM multi precision integer
T_TRUE true T_TRUE true
@ -88,7 +88,7 @@ The data for type T_NIL, T_FALSE, T_TRUE are nil, true, false
respectively. They are singletons for the data type. respectively. They are singletons for the data type.
The T_FIXNUM data is the 31bit length fixed integer (63bit length on The T_FIXNUM data is the 31bit length fixed integer (63bit length on
some machines), which can be conver to the C integer by using some machines), which can be convert to the C integer by using
FIX2INT() macro. There also be NUM2INT() which converts any Ruby FIX2INT() macro. There also be NUM2INT() which converts any Ruby
numbers into C integer. The NUM2INT() macro includes type check, so numbers into C integer. The NUM2INT() macro includes type check, so
the exception will be raised if conversion failed. the exception will be raised if conversion failed.
@ -127,7 +127,7 @@ structures are defined in <ruby.h>.
To convert C numbers to Ruby value, use these macros. To convert C numbers to Ruby value, use these macros.
INT2FIX() for intergers within 31bits. INT2FIX() for integers within 31bits.
INT2NUM() for arbitrary sized integer. INT2NUM() for arbitrary sized integer.
INT2NUM() converts integers into Bignums, if it is out of FIXNUM INT2NUM() converts integers into Bignums, if it is out of FIXNUM
@ -139,7 +139,7 @@ As I already told, it is not recommended to modify object's internal
structure. To manipulate objects, use functions supplied by Ruby structure. To manipulate objects, use functions supplied by Ruby
interpreter. Useful functions are listed below (not all): interpreter. Useful functions are listed below (not all):
String funtions String functions
rb_str_new(char *ptr, int len) rb_str_new(char *ptr, int len)
@ -200,14 +200,14 @@ To define class or module, use functions below:
VALUE rb_define_class(char *name, VALUE super) VALUE rb_define_class(char *name, VALUE super)
VALUE rb_define_module(char *name) VALUE rb_define_module(char *name)
These functions return the newly created class ot module. You may These functions return the newly created class or module. You may
want to save this reference into the variable to use later. want to save this reference into the variable to use later.
2.1.2 Method/singleton method definition 2.1.2 Method/singleton method definition
To define methods or singleton methods, use functions below: To define methods or singleton methods, use functions below:
void rb_define_method(VALUE class, char *name, void rb_define_method(VALUE klass, char *name,
VALUE (*func)(), int argc) VALUE (*func)(), int argc)
void rb_define_singleton_method(VALUE object, char *name, void rb_define_singleton_method(VALUE object, char *name,
@ -237,7 +237,7 @@ actual arguments.
There're two more functions to define method. One is to define There're two more functions to define method. One is to define
private method: private method:
void rb_define_private_method(VALUE class, char *name, void rb_define_private_method(VALUE klass, char *name,
VALUE (*func)(), int argc) VALUE (*func)(), int argc)
The other is to define module function, which is private AND singleton The other is to define module function, which is private AND singleton
@ -266,7 +266,7 @@ in Kernel module, can be defined using:
We have 2 functions to define constants: We have 2 functions to define constants:
void rb_define_const(VALUE class, char *name, VALUE val) void rb_define_const(VALUE klass, char *name, VALUE val)
void rb_define_global_const(char *name, VALUE val) void rb_define_global_const(char *name, VALUE val)
The former is to define constant under specified class/module. The The former is to define constant under specified class/module. The
@ -330,7 +330,7 @@ To access the constants of the class/module:
See 2.1.3 for defining new constant. See 2.1.3 for defining new constant.
3. Informatin sharing between Ruby and C 3. Information sharing between Ruby and C
3.1 Ruby constant that C can be accessed from C 3.1 Ruby constant that C can be accessed from C
@ -353,7 +353,7 @@ variables. To define them, you can use functions listed below:
void rb_define_variable(char *name, VALUE *var) void rb_define_variable(char *name, VALUE *var)
This function defines the variable which is shared by the both world. This function defines the variable which is shared by the both world.
The value of the global variable pointerd by `var', can be accessed The value of the global variable pointed by `var', can be accessed
through Ruby's global variable named `name'. through Ruby's global variable named `name'.
You can define read-only (from Ruby, of course) variable by the You can define read-only (from Ruby, of course) variable by the
@ -387,7 +387,7 @@ The prototypes of the getter and setter functions are as following:
To wrapping and objectify the C pointer as Ruby object (so called To wrapping and objectify the C pointer as Ruby object (so called
DATA), use Data_Wrap_Struct(). DATA), use Data_Wrap_Struct().
Data_Wrap_Struct(class,mark,free,ptr) Data_Wrap_Struct(klass,mark,free,ptr)
Data_Wrap_Struct() returns a created DATA object. The class argument Data_Wrap_Struct() returns a created DATA object. The class argument
is the class for the DATA object. The mark argument is the function is the class for the DATA object. The mark argument is the function
@ -397,14 +397,14 @@ free, will be called from garbage collector.
You can allocate and wrap the structure in one step. You can allocate and wrap the structure in one step.
Data_Make_Struct(class, type, mark, free, sval) Data_Make_Struct(klass, type, mark, free, sval)
This macro returns an allocated Data object, wrapping the pointer to This macro returns an allocated Data object, wrapping the pointer to
the structure, which is also allocated. This macro works like: the structure, which is also allocated. This macro works like:
(sval = ALLOC(type), Data_Wrap_Struct(class, mark, free, sval)) (sval = ALLOC(type), Data_Wrap_Struct(klass, mark, free, sval))
Arguments, class, mark, free, works like thier counterpart of Arguments, klass, mark, free, works like their counterpart of
Data_Wrap_Struct(). The pointer to allocated structure will be Data_Wrap_Struct(). The pointer to allocated structure will be
assigned to sval, which should be the pointer to the type specified. assigned to sval, which should be the pointer to the type specified.
@ -445,12 +445,12 @@ You need to design the library features, before making it.
You need to write C code for your extension library. If your library You need to write C code for your extension library. If your library
has only one source file, choosing ``LIBRARY.c'' as a file name is has only one source file, choosing ``LIBRARY.c'' as a file name is
preferred. On the other hand, in case your library has prural source preferred. On the other hand, in case your library has plural source
files, avoid chooing ``LIBRARY.c'' for a file name. It may conflict files, avoid choosing ``LIBRARY.c'' for a file name. It may conflict
with intermediate file ``LIBRARY.o'' on some platforms. with intermediate file ``LIBRARY.o'' on some platforms.
Ruby will execute the initializing function named ``Init_LIBRARY'' in Ruby will execute the initializing function named ``Init_LIBRARY'' in
the library. For exapmle, ``Init_dbm()'' will be executed when loading the library. For example, ``Init_dbm()'' will be executed when loading
the library. the library.
Here's the example of an initializing function. Here's the example of an initializing function.
@ -484,7 +484,7 @@ struct dbmdata {
}; };
obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp); obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp);
-- --
This code wraps dbmdata structure into Ruby object. We avoid wrapping This code wraps dbmdata structure into Ruby object. We avoid wrapping
@ -517,15 +517,15 @@ fdbm_delete(obj, keystr)
The first argument of the C function is the self, the rest are the The first argument of the C function is the self, the rest are the
arguments to the method. arguments to the method.
Second, the methods with arbtrary number of arguments receives Second, the methods with arbitrary number of arguments receives
arguments like this: arguments like this:
-- --
static VALUE static VALUE
fdbm_s_open(argc, argv, class) fdbm_s_open(argc, argv, klass)
int argc; int argc;
VALUE *argv; VALUE *argv;
VALUE class; VALUE klass;
{ {
: :
if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) { if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
@ -540,10 +540,10 @@ argument is the C array of the method arguments. And the third
argument is the receiver of the method. argument is the receiver of the method.
You can use the function rb_scan_args() to check and retrieve the You can use the function rb_scan_args() to check and retrieve the
arguments. For exapmle "11" means, the method requires at least one arguments. For example "11" means, the method requires at least one
argument, and at most receives two arguments. argument, and at most receives two arguments.
The methods with arbtrary number of arguments can receives arguments The methods with arbitrary number of arguments can receives arguments
by Ruby's array, like this: by Ruby's array, like this:
-- --
@ -576,7 +576,7 @@ need to put
require 'mkmf' require 'mkmf'
at the top of the file. You can use the funcitons below to check the at the top of the file. You can use the functions below to check the
condition. condition.
have_library(lib, func): check whether library containing function exists. have_library(lib, func): check whether library containing function exists.
@ -720,14 +720,14 @@ const: false object
** C pointer wrapping ** C pointer wrapping
Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval) Data_Wrap_Struct(VALUE klass, void (*mark)(), void (*free)(), void *sval)
Wrap C pointer into Ruby object. If object has references to other Wrap C pointer into Ruby object. If object has references to other
Ruby object, they should be marked by using mark function during GC Ruby object, they should be marked by using mark function during GC
process. Otherwise, mark should be 0. When this object is no longer process. Otherwise, mark should be 0. When this object is no longer
referred by anywhere, the pointer will be discarded by free function. referred by anywhere, the pointer will be discarded by free function.
Data_Make_Struct(class, type, mark, free, sval) Data_Make_Struct(klass, type, mark, free, sval)
This macro allocates memory using malloc(), assigns it to the variable This macro allocates memory using malloc(), assigns it to the variable
sval, and returns the DATA encapsulating the pointer to memory region. sval, and returns the DATA encapsulating the pointer to memory region.
@ -754,9 +754,9 @@ Defines new Ruby module.
VALUE rb_define_module_under(VALUE module, char *name, VALUE super) VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
Defines new Ruby module, under the modules's namespace. Defines new Ruby module, under the module's namespace.
void rb_include_module(VALUE class, VALUE module) void rb_include_module(VALUE klass, VALUE module)
Includes module into class. If class already includes it, just Includes module into class. If class already includes it, just
ignore. ignore.
@ -817,13 +817,13 @@ Defines a new constant under the class/module.
void rb_define_global_const(char *name, VALUE val) void rb_define_global_const(char *name, VALUE val)
Defines global contant. This is just work as Defines global constant. This is just work as
rb_define_const(cKernal, name, val) rb_define_const(cKernal, name, val)
** Method Definition ** Method Definition
rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc) rb_define_method(VALUE klass, char *name, VALUE (*func)(), int argc)
Defines a method for the class. func is the function pointer. argc Defines a method for the class. func is the function pointer. argc
is the number of arguments. if argc is -1, the function will receive is the number of arguments. if argc is -1, the function will receive
@ -831,20 +831,20 @@ is the number of arguments. if argc is -1, the function will receive
receive 2 arguments, self and args, where args is the Ruby array of receive 2 arguments, self and args, where args is the Ruby array of
the method arguments. the method arguments.
rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc) rb_define_private_method(VALUE klass, char *name, VALUE (*func)(), int argc)
Defines a private method for the class. Arguments are same as Defines a private method for the class. Arguments are same as
rb_define_method(). rb_define_method().
rb_define_singleton_method(VALUE class, char *name, VALUE (*func)(), int argc) rb_define_singleton_method(VALUE klass, char *name, VALUE (*func)(), int argc)
Defines a singleton method. Arguments are same as rb_define_method(). Defines a singleton method. Arguments are same as rb_define_method().
rb_scan_args(int argc, VALUE *argv, char *fmt, ...) rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
Retrieve argument from argc, argv. The fmt is the format string for Retrieve argument from argc, argv. The fmt is the format string for
the arguments, such as "12" for 1 non-optinal argument, 2 optinal the arguments, such as "12" for 1 non-optional argument, 2 optional
aruguments. If `*' appears at the end of fmt, it means the rest of arguments. If `*' appears at the end of fmt, it means the rest of
the arguments are assigned to corresponding variable, packed in the arguments are assigned to corresponding variable, packed in
array. array.
@ -870,7 +870,7 @@ Returns ID corresponding the name.
Returns the name corresponding ID. Returns the name corresponding ID.
char *rb_class2name(VALUE class) char *rb_class2name(VALUE klass)
Returns the name of the class. Returns the name of the class.
@ -934,7 +934,7 @@ will be done for fatal error, but ensure blocks will be executed.
void rb_bug(char *fmt, ...) void rb_bug(char *fmt, ...)
Termintates the interpreter immediately. This function should be Terminates the interpreter immediately. This function should be
called under the situation caused by the bug in the interpreter. No called under the situation caused by the bug in the interpreter. No
exception handling nor ensure execution will be done. exception handling nor ensure execution will be done.

View file

@ -39,6 +39,7 @@ Ruby
CVS password: guest CVS password: guest
$ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs checkout ruby $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs checkout ruby
* ホームページ * ホームページ
RubyのホームページのURLは RubyのホームページのURLは
@ -134,7 +135,7 @@ UNIX
* 配布条件 * 配布条件
RUbyはフリーソフトウェアですGPL(the GNU General Public RubyはフリーソフトウェアですGPL(the GNU General Public
Licence)または以下に示す条件でRubyを再配布できますGPLにつ Licence)または以下に示す条件でRubyを再配布できますGPLにつ
いてはCOPYINGファイルを参照して下さい いてはCOPYINGファイルを参照して下さい
@ -171,7 +172,7 @@ Licence)
4. 他のプログラムへの引用はいかなる目的であれ自由です.た 4. 他のプログラムへの引用はいかなる目的であれ自由です.た
だしRubyに含まれる他の作者によるコードはそれぞれの だしRubyに含まれる他の作者によるコードはそれぞれの
作者の意向による制限が加えられます具体的にはgc.c(一部) 作者の意向による制限が加えられます具体的にはgc.c(一部)
util.c(一部)st.[ch]regex.[ch] および. /missingディ util.c(一部)st.[ch]regex.[ch] および ./missingディ
レクトリ下のファイル群が該当します.それぞれの配布条件 レクトリ下のファイル群が該当します.それぞれの配布条件
などに付いては各ファイルを参照してください. などに付いては各ファイルを参照してください.

View file

@ -48,7 +48,7 @@
#define DOSISH 1 #define DOSISH 1
#endif #endif
#if defined(MSDOS) || defined(NT) || defined(__human68k__) #if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(OS2)
#define PATH_SEP ";" #define PATH_SEP ";"
#else #else
#define PATH_SEP ":" #define PATH_SEP ":"

9
eval.c
View file

@ -5359,7 +5359,7 @@ blk_copy_prev(block)
MEMCPY(tmp, block->prev, struct BLOCK, 1); MEMCPY(tmp, block->prev, struct BLOCK, 1);
if (tmp->frame.argc > 0) { if (tmp->frame.argc > 0) {
tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc); tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc); MEMCPY(tmp->frame.argv, block->prev->frame.argv, VALUE, tmp->frame.argc);
} }
scope_dup(tmp->scope); scope_dup(tmp->scope);
block->prev = tmp; block->prev = tmp;
@ -6016,8 +6016,8 @@ timeofday()
static thread_t main_thread; static thread_t main_thread;
#define ADJ(addr) (void*)(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr) #define STACK(addr) (th->stk_pos<(VALUE*)(addr) && (VALUE*)(addr)<th->stk_pos+th->stk_len)
#define STACK(addr) (th->stk_pos<(addr) && (addr)<th->stk_pos+th->stk_len) #define ADJ(addr) (void*)(STACK(addr)?(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr):(VALUE*)(addr))
static void static void
thread_mark(th) thread_mark(th)
@ -6041,6 +6041,7 @@ thread_mark(th)
rb_mark_tbl(th->locals); rb_mark_tbl(th->locals);
/* mark data in copied stack */ /* mark data in copied stack */
if (th == curr_thread) return;
if (th->status == THREAD_KILLED) return; if (th->status == THREAD_KILLED) return;
if (th->stk_len == 0) return; /* stack not active, no need to mark. */ if (th->stk_len == 0) return; /* stack not active, no need to mark. */
if (th->stk_ptr) { if (th->stk_ptr) {
@ -6054,7 +6055,7 @@ thread_mark(th)
frame = ADJ(frame); frame = ADJ(frame);
rb_gc_mark_frame(frame); rb_gc_mark_frame(frame);
if (frame->tmp) { if (frame->tmp) {
struct FRAME *tmp = ADJ(frame->tmp); struct FRAME *tmp = frame->tmp;
while (tmp && tmp != top_frame) { while (tmp && tmp != top_frame) {
tmp = ADJ(tmp); tmp = ADJ(tmp);

View file

@ -1,10 +1,12 @@
require 'mkmf' require 'mkmf'
dir_config("dbm") dir_config("dbm")
have_library("gdbm", "dbm_open") or if have_library("gdbm", "dbm_open")
have_library("db", "dbm_open") or gdbm = true
have_library("dbm", "dbm_open") end
gdbm or have_library("db", "dbm_open") or have_library("dbm", "dbm_open")
have_header("cdefs.h") have_header("cdefs.h")
if have_header("ndbm.h") and have_func("dbm_open") if have_header("ndbm.h") and have_func("dbm_open")
have_func("dbm_clearerr") have_func("dbm_clearerr") unless gdbm
create_makefile("dbm") create_makefile("dbm")
end end

View file

@ -25,7 +25,7 @@ if a or b or c
etc_grep_header("pw_quota") etc_grep_header("pw_quota")
etc_grep_header("pw_age") etc_grep_header("pw_age")
etc_grep_header("pw_class") etc_grep_header("pw_class")
etc_grep_header("pw_comment") etc_grep_header("pw_comment") unless /cygwin/ === RUBY_PLATFORM
etc_grep_header("pw_expire") etc_grep_header("pw_expire")
create_makefile("etc") create_makefile("etc")
end end

View file

@ -19,10 +19,6 @@ $extlist = []
$includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@') $includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@')
$cache_mod = false
$lib_cache = {}
$func_cache = {}
$hdr_cache = {}
$top_srcdir = "@top_srcdir@" $top_srcdir = "@top_srcdir@"
if $top_srcdir !~ "^/" if $top_srcdir !~ "^/"
# get absolute path # get absolute path
@ -36,21 +32,6 @@ $:.push $top_srcdir+"/lib"
require 'find' require 'find'
if File.exist?("config.cache") then
f = open("config.cache", "r")
while f.gets
case $_
when /^lib: (.+) (yes|no)/
$lib_cache[$1] = $2
when /^func: ([\w_]+) (yes|no)/
$func_cache[$1] = $2
when /^hdr: (.+) (yes|no)/
$hdr_cache[$1] = $2
end
end
f.close
end
def older(file1, file2) def older(file1, file2)
if !File.exist?(file1) then if !File.exist?(file1) then
return true return true
@ -175,15 +156,6 @@ def append_library(libs, lib)
end end
def have_library(lib, func="main") def have_library(lib, func="main")
if $lib_cache[lib]
if $lib_cache[lib] == "yes"
$libs = append_library($libs, lib)
return true
else
return false
end
end
if func && func != "" if func && func != ""
libs = append_library($libs, lib) libs = append_library($libs, lib)
if /mswin32/ =~ RUBY_PLATFORM if /mswin32/ =~ RUBY_PLATFORM
@ -208,8 +180,6 @@ int t() { #{func}(); return 0; }
SRC SRC
end end
unless r unless r
$lib_cache[lib] = 'no'
$cache_mod = true
return false return false
end end
else else
@ -217,8 +187,6 @@ SRC
end end
$libs = libs $libs = libs
$lib_cache[lib] = 'yes'
$cache_mod = true
return true return true
end end
@ -240,15 +208,6 @@ SRC
end end
def have_func(func) def have_func(func)
if $func_cache[func]
if $func_cache[func] == "yes"
$defs.push(format("-DHAVE_%s", func.upcase))
return true
else
return false
end
end
libs = $libs libs = $libs
if /mswin32/ =~ RUBY_PLATFORM if /mswin32/ =~ RUBY_PLATFORM
@ -273,38 +232,20 @@ int t() { #{func}(); return 0; }
SRC SRC
end end
unless r unless r
$func_cache[func] = 'no'
$cache_mod = true
return false return false
end end
$defs.push(format("-DHAVE_%s", func.upcase)) $defs.push(format("-DHAVE_%s", func.upcase))
$func_cache[func] = 'yes'
$cache_mod = true
return true return true
end end
def have_header(header) def have_header(header)
if $hdr_cache[header]
if $hdr_cache[header] == "yes"
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
return true
else
return false
end
end
unless try_cpp(<<"SRC") unless try_cpp(<<"SRC")
#include <#{header}> #include <#{header}>
SRC SRC
$hdr_cache[header] = 'no'
$cache_mod = true
return false return false
end end
$hdr_cache[header] = 'yes'
header.tr!("a-z./\055", "A-Z___") header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header)) $defs.push(format("-DHAVE_%s", header))
$cache_mod = true
return true return true
end end
@ -676,20 +617,6 @@ for d in Dir["#{$top_srcdir}/ext/*"]
extmake(d) extmake(d)
end end
if $cache_mod
f = open("config.cache", "w")
for k,v in $lib_cache
f.printf "lib: %s %s\n", k, v
end
for k,v in $func_cache
f.printf "func: %s %s\n", k, v
end
for k,v in $hdr_cache
f.printf "hdr: %s %s\n", k, v
end
f.close
end
if $install or $clean if $install or $clean
Dir.chdir ".." Dir.chdir ".."
exit exit

View file

@ -334,9 +334,6 @@ fgdbm_store(obj, keystr, valstr)
dbmp->di_size = -1; dbmp->di_size = -1;
dbm = dbmp->di_dbm; dbm = dbmp->di_dbm;
if (gdbm_store(dbm, key, val, GDBM_REPLACE)) { if (gdbm_store(dbm, key, val, GDBM_REPLACE)) {
#ifdef HAVE_DBM_CLAERERR
gdbm_clearerr(dbm);
#endif
if (errno == EPERM) rb_sys_fail(0); if (errno == EPERM) rb_sys_fail(0);
rb_raise(rb_eRuntimeError, "dbm_store failed"); rb_raise(rb_eRuntimeError, "dbm_store failed");
} }

View file

@ -22,11 +22,11 @@ PTY.spawn("/bin/csh") do
begin begin
while true while true
c = r_pty.getc c = r_pty.sysread(512)
next if c.nil? break if c.nil?
print c.chr print c
STDOUT.flush STDOUT.flush
logfile.print c.chr logfile.print c
end end
rescue rescue
# print $@,':',$!,"\n" # print $@,':',$!,"\n"

View file

@ -7,10 +7,10 @@ when /mswin32/
test_func = "WSACleanup" test_func = "WSACleanup"
have_library("wsock32", "WSACleanup") have_library("wsock32", "WSACleanup")
when /cygwin/ when /cygwin/
$LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib") # $LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib")
$CFLAGS << " -I/usr/include" # $CFLAGS << " -I/usr/include"
test_func = "socket" test_func = "socket"
have_library("bind", "gethostbyaddr") # have_library("bind", "gethostbyaddr")
when /beos/ when /beos/
test_func = "socket" test_func = "socket"
have_library("net", "socket") have_library("net", "socket")

View file

@ -8,6 +8,8 @@ require "tcltklib"
require "tkutil" require "tkutil"
module TkComm module TkComm
WidgetClassNames = {}
None = Object.new None = Object.new
def None.to_s def None.to_s
'None' 'None'
@ -34,7 +36,7 @@ module TkComm
return path return path
end end
ruby_class = TkClassBind::WidgetClassNameTBL[tk_class] ruby_class = WidgetClassNames[tk_class]
gen_class_name = ruby_class.name + 'GeneratedOnTk' gen_class_name = ruby_class.name + 'GeneratedOnTk'
unless Object.const_defined? gen_class_name unless Object.const_defined? gen_class_name
eval "class #{gen_class_name}<#{ruby_class.name} eval "class #{gen_class_name}<#{ruby_class.name}
@ -328,45 +330,36 @@ module TkComm
end end
end end
def _bind_core(mode, path, context, cmd, args=nil) def _bind_core(mode, what, context, cmd, args=nil)
id = install_bind(cmd, args) id = install_bind(cmd, args) if cmd
begin begin
tk_call 'bind', path, "<#{tk_event_sequence(context)}>", mode + id tk_call(*(what + ["<#{tk_event_sequence(context)}>", mode + id]))
rescue rescue
uninstall_cmd(id) uninstall_cmd(id) if cmd
fail fail
end end
end end
def _bind(path, context, cmd, args=nil) def _bind(what, context, cmd, args=nil)
_bind_core('', path, context, cmd, args) _bind_core('', what, context, cmd, args)
end end
def _bind_append(path, context, cmd, args=nil) def _bind_append(what, context, cmd, args=nil)
_bind_core('+', path, context, cmd, args) _bind_core('+', what, context, cmd, args)
end end
private :install_bind, :tk_event_sequence, :_bind_core, :_bind, :_bind_append private :install_bind, :tk_event_sequence, :_bind_core, :_bind, :_bind_append
def bind_all(context, cmd=Proc.new, args=nil) def bind_all(context, cmd=Proc.new, args=nil)
_bind 'all', context, cmd, args _bind(['bind', 'all'], context, cmd, args)
end end
def bind_append_all(context, cmd=Proc.new, args=nil) def bind_append_all(context, cmd=Proc.new, args=nil)
_bind_append 'all', context, cmd, args _bind_append(['bind', 'all'], context, cmd, args)
end end
def bind(tagOrClass, context, cmd=Proc.new, args=nil) def _bindinfo(what, context=nil)
_bind tagOrClass, context, cmd, args
end
def bind_append(tagOrClass, context, cmd=Proc.new, args=nil)
_bind_append tagOrClass, context, cmd, args
end
def _bindinfo(tagOrClass, context=nil)
if context if context
(tk_call('bind', tagOrClass, tk_call(*what+["<#{tk_event_sequence(context)}>"]).collect {|cmdline|
"<#{tk_event_sequence(context)}>")).collect{|cmdline|
if cmdline =~ /^rb_out (c\d+)\s+(.*)$/ if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
[Tk_CMDTBL[$1], $2] [Tk_CMDTBL[$1], $2]
else else
@ -374,14 +367,14 @@ module TkComm
end end
} }
else else
tk_split_list(tk_call 'bind', tagOrClass).collect{|seq| tk_split_list(tk_call(*what)).collect{|seq|
seq[1..-2].gsub(/></,',') seq[1..-2].gsub(/></,',')
} }
end end
end end
def bindinfo(tagOrClass, context=nil) def bindinfo(tagOrClass, context=nil)
_bindinfo tagOrClass, context _bindinfo(['bind', tagOrClass], context)
end end
def pack(*args) def pack(*args)
@ -971,7 +964,7 @@ class TkVarAccess<TkVariable
def initialize(varname, val=nil) def initialize(varname, val=nil)
@id = varname @id = varname
if val if val
s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #"
INTERP._eval(format('global %s; set %s %s', @id, @id, s)) INTERP._eval(format('global %s; set %s %s', @id, @id, s))
end end
end end
@ -1648,15 +1641,15 @@ class TkObject<TkKernel
end end
def bind(context, cmd=Proc.new, args=nil) def bind(context, cmd=Proc.new, args=nil)
_bind path, context, cmd, args _bind(["bind", to_eval], context, cmd, args)
end end
def bind_append(context, cmd=Proc.new, args=nil) def bind_append(context, cmd=Proc.new, args=nil)
_bind_append path, context, cmd, args _bind_append(["bind", to_eval], context, cmd, args)
end end
def bindinfo(context=nil) def bindinfo(context=nil)
_bindinfo path, context _bindinfo(['bind', to_eval], context)
end end
def event_generate(context, keys=nil) def event_generate(context, keys=nil)
@ -1681,28 +1674,8 @@ class TkObject<TkKernel
end end
end end
module TkClassBind
WidgetClassNameTBL = {}
def TkClassBind.name2class(name)
WidgetClassNameTBL[name]
end
def bind(context, cmd=Proc.new, args=nil)
Tk.bind to_eval, context, cmd, args
end
def bind_append(context, cmd=Proc.new, args=nil)
Tk.bind_append to_eval, context, cmd, args
end
def bindinfo(context=nil)
Tk.bindinfo to_eval, context
end
end
class TkWindow<TkObject class TkWindow<TkObject
extend TkClassBind # extend TkClassBind
def initialize(parent=nil, keys=nil) def initialize(parent=nil, keys=nil)
install_win(if parent then parent.path end) install_win(if parent then parent.path end)
@ -1853,7 +1826,7 @@ class TkWindow<TkObject
tk_split_list(tk_call('bindtags', path)).collect{|tag| tk_split_list(tk_call('bindtags', path)).collect{|tag|
if tag == nil if tag == nil
'.' '.'
elsif tag.kind_of?(String) && (cls = TkClassBind.name2class(tag)) elsif tag.kind_of?(String) && (cls = WidgetClassNames[tag])
cls cls
else else
tag tag
@ -1874,7 +1847,7 @@ class TkRoot<TkWindow
end end
WidgetClassName = 'Tk'.freeze WidgetClassName = 'Tk'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -1891,7 +1864,7 @@ class TkToplevel<TkWindow
include Wm include Wm
WidgetClassName = 'Toplevel'.freeze WidgetClassName = 'Toplevel'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -1951,7 +1924,7 @@ end
class TkFrame<TkWindow class TkFrame<TkWindow
WidgetClassName = 'Frame'.freeze WidgetClassName = 'Frame'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -1991,7 +1964,7 @@ end
class TkLabel<TkWindow class TkLabel<TkWindow
WidgetClassName = 'Label'.freeze WidgetClassName = 'Label'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -2004,7 +1977,7 @@ class TkLabel<TkWindow
end end
class TkButton<TkLabel class TkButton<TkLabel
TkClassBind::WidgetClassNameTBL['Button'] = self WidgetClassNames['Button'] = self
def TkButton.to_eval def TkButton.to_eval
'Button' 'Button'
end end
@ -2020,7 +1993,7 @@ class TkButton<TkLabel
end end
class TkRadioButton<TkButton class TkRadioButton<TkButton
TkClassBind::WidgetClassNameTBL['Radiobutton'] = self WidgetClassNames['Radiobutton'] = self
def TkRadioButton.to_eval def TkRadioButton.to_eval
'Radiobutton' 'Radiobutton'
end end
@ -2039,7 +2012,7 @@ class TkRadioButton<TkButton
end end
class TkCheckButton<TkRadioButton class TkCheckButton<TkRadioButton
TkClassBind::WidgetClassNameTBL['Checkbutton'] = self WidgetClassNames['Checkbutton'] = self
def TkCheckButton.to_eval def TkCheckButton.to_eval
'Checkbutton' 'Checkbutton'
end end
@ -2052,7 +2025,7 @@ class TkCheckButton<TkRadioButton
end end
class TkMessage<TkLabel class TkMessage<TkLabel
TkClassBind::WidgetClassNameTBL['Message'] = self WidgetClassNames['Message'] = self
def TkMessage.to_eval def TkMessage.to_eval
'Message' 'Message'
end end
@ -2063,7 +2036,7 @@ end
class TkScale<TkWindow class TkScale<TkWindow
WidgetClassName = 'Scale'.freeze WidgetClassName = 'Scale'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -2091,7 +2064,7 @@ end
class TkScrollbar<TkWindow class TkScrollbar<TkWindow
WidgetClassName = 'Scrollbar'.freeze WidgetClassName = 'Scrollbar'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -2158,7 +2131,7 @@ class TkTextWin<TkWindow
end end
class TkListbox<TkTextWin class TkListbox<TkTextWin
TkClassBind::WidgetClassNameTBL['Listbox'] = self WidgetClassNames['Listbox'] = self
def TkListbox.to_eval def TkListbox.to_eval
'Listbox' 'Listbox'
end end
@ -2315,7 +2288,7 @@ class TkMenu<TkWindow
include TkTreatMenuEntryFont include TkTreatMenuEntryFont
WidgetClassName = 'Menu'.freeze WidgetClassName = 'Menu'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -2395,7 +2368,7 @@ class TkMenu<TkWindow
end end
class TkMenubutton<TkLabel class TkMenubutton<TkLabel
TkClassBind::WidgetClassNameTBL['Menubutton'] = self WidgetClassNames['Menubutton'] = self
def TkMenubutton.to_eval def TkMenubutton.to_eval
'Menubutton' 'Menubutton'
end end

View file

@ -131,7 +131,7 @@ class TkCanvas<TkWindow
include TkTreatCItemFont include TkTreatCItemFont
WidgetClassName = 'Canvas'.freeze WidgetClassName = 'Canvas'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -179,31 +179,15 @@ class TkCanvas<TkWindow
end end
def itembind(tag, context, cmd=Proc.new, args=nil) def itembind(tag, context, cmd=Proc.new, args=nil)
id = install_bind(cmd, args) _bind([path, "bind", tagid(tag)], context, cmd, args)
begin end
tk_send 'bind', tagid(tag), "<#{tk_event_sequence(context)}>", id
rescue def itembind_append(tag, context, cmd=Proc.new, args=nil)
uninstall_cmd(cmd) _bind_append([path, "bind", tagid(tag)], context, cmd, args)
fail
end
# @cmdtbl.push id
end end
def itembindinfo(tag, context=nil) def itembindinfo(tag, context=nil)
if context _bindinfo([path, "bind", tagid(tag)], context)
(tk_send('bind', tagid(tag),
"<#{tk_event_sequence(context)}>")).collect{|cmdline|
if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
[Tk_CMDTBL[$1], $2]
else
cmdline
end
}
else
tk_split_list(tk_send 'bind', tagid(tag)).filter{|seq|
seq[1..-2].gsub(/></,',')
}
end
end end
def canvasx(x, *args) def canvasx(x, *args)

View file

@ -7,7 +7,7 @@ require 'tk.rb'
class TkEntry<TkLabel class TkEntry<TkLabel
WidgetClassName = 'Entry'.freeze WidgetClassName = 'Entry'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end

View file

@ -129,7 +129,7 @@ class TkText<TkTextWin
include TkTreatTextTagFont include TkTreatTextTagFont
WidgetClassName = 'Text'.freeze WidgetClassName = 'Text'.freeze
TkClassBind::WidgetClassNameTBL[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
def self.to_eval def self.to_eval
WidgetClassName WidgetClassName
end end
@ -235,40 +235,20 @@ class TkText<TkTextWin
tk_send 'xview', '-pickplace', *what tk_send 'xview', '-pickplace', *what
end end
def tag_add(tag,index1,index2=None) def tag_add(tag, index1, index2=None)
tk_send 'tag', 'add', tag, index1, index2 tk_send 'tag', 'add', tag, index1, index2
end end
def _tag_bind_core(mode, tag, seq, cmd=Proc.new, args=nil)
id = install_bind(cmd, args)
tk_send 'tag', 'bind', tag, "<#{tk_event_sequence(seq)}>", mode + id
# _addcmd cmd
end
private :_tag_bind_core
def tag_bind(tag, seq, cmd=Proc.new, args=nil) def tag_bind(tag, seq, cmd=Proc.new, args=nil)
_tag_bind_core('', tag, seq, cmd, args=nil) _bind(['tag', 'bind', tag], seq, cmd, args)
end end
def tag_bind_append(tag, seq, cmd=Proc.new, args=nil) def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
_tag_bind_core('+', tag, seq, cmd, args=nil) _bind_append(['tag', 'bind', tag], seq, cmd, args)
end end
def tag_bindinfo(tag, context=nil) def tag_bindinfo(tag, context=nil)
if context _bindinfo(['tag', 'bind', tag], context)
(tk_send('tag', 'bind', tag,
"<#{tk_event_sequence(context)}>")).collect{|cmdline|
if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
[Tk_CMDTBL[$1], $2]
else
cmdline
end
}
else
tk_split_list(tk_send('tag', 'bind', tag)).filter{|seq|
seq[1..-2].gsub(/></,',')
}
end
end end
def tag_cget(tag, key) def tag_cget(tag, key)
@ -521,40 +501,17 @@ class TkTextTag<TkObject
def configinfo(key=nil) def configinfo(key=nil)
@t.tag_configinfo @id, key @t.tag_configinfo @id, key
end end
# def configinfo(key=nil)
# if key
# conf = tk_split_list(tk_call(@t.path, 'tag','configure',@id,"-#{key}"))
# conf[0] = conf[0][1..-1]
# conf
# else
# tk_split_list(tk_call(@t.path, 'tag', 'configure', @id)).collect{|conf|
# conf[0] = conf[0][1..-1]
# conf
# }
# end
# end
def bind(seq, cmd=Proc.new, args=nil) def bind(seq, cmd=Proc.new, args=nil)
id = install_bind(cmd, args) _bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
tk_call @t.path, 'tag', 'bind', @id, "<#{tk_event_sequence(seq)}>", id end
# @t._addcmd cmd
def bind_append(seq, cmd=Proc.new, args=nil)
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
end end
def bindinfo(context=nil) def bindinfo(context=nil)
if context _bindinfo([@t.path, 'tag', 'bind', @id], context)
(tk_call(@t.path, 'tag', 'bind', @id,
"<#{tk_event_sequence(context)}>")).collect{|cmdline|
if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
[Tk_CMDTBL[$1], $2]
else
cmdline
end
}
else
tk_split_list(tk_call(@t.path, 'tag', 'bind', @id)).filter{|seq|
seq[1..-2].gsub(/></,',')
}
end
end end
def raise(above=None) def raise(above=None)

6
gc.c
View file

@ -890,7 +890,7 @@ void
rb_gc() rb_gc()
{ {
struct gc_list *list; struct gc_list *list;
struct FRAME *frame; struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */
jmp_buf save_regs_gc_mark; jmp_buf save_regs_gc_mark;
VALUE stack_end; VALUE stack_end;
@ -907,8 +907,6 @@ rb_gc()
/* mark frame stack */ /* mark frame stack */
for (frame = ruby_frame; frame; frame = frame->prev) { for (frame = ruby_frame; frame; frame = frame->prev) {
rb_gc_mark_frame(frame); rb_gc_mark_frame(frame);
}
for (frame = ruby_frame; frame; frame = frame->prev) {
if (frame->tmp) { if (frame->tmp) {
struct FRAME *tmp = frame->tmp; struct FRAME *tmp = frame->tmp;
while (tmp) { while (tmp) {
@ -924,7 +922,7 @@ rb_gc()
FLUSH_REGISTER_WINDOWS; FLUSH_REGISTER_WINDOWS;
/* This assumes that all registers are saved into the jmp_buf */ /* This assumes that all registers are saved into the jmp_buf */
setjmp(save_regs_gc_mark); setjmp(save_regs_gc_mark);
mark_locations_array((VALUE*)&save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *)); mark_locations_array((VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *));
rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)&stack_end); rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)&stack_end);
#if defined(THINK_C) || defined(__human68k__) #if defined(THINK_C) || defined(__human68k__)
#ifndef __human68k__ #ifndef __human68k__

16
io.c
View file

@ -184,7 +184,7 @@ io_write(io, str)
str = rb_obj_as_string(str); str = rb_obj_as_string(str);
if (RSTRING(str)->len == 0) return INT2FIX(0); if (RSTRING(str)->len == 0) return INT2FIX(0);
if (BUILTIN_TYPE(io) != T_FILE) { if (TYPE(io) != T_FILE) {
/* port is not IO, call write method for it. */ /* port is not IO, call write method for it. */
return rb_funcall(io, id_write, 1, str); return rb_funcall(io, id_write, 1, str);
} }
@ -1823,13 +1823,12 @@ rb_io_printf(argc, argv, out)
VALUE argv[]; VALUE argv[];
VALUE out; VALUE out;
{ {
rb_funcall(out, id_write, 1, rb_f_sprintf(argc, argv)); io_write(out, rb_f_sprintf(argc, argv));
return Qnil; return Qnil;
} }
static VALUE static VALUE
rb_rb_f_printf(argc, argv) rb_f_printf(argc, argv)
int argc; int argc;
VALUE argv[]; VALUE argv[];
{ {
@ -1839,15 +1838,12 @@ rb_rb_f_printf(argc, argv)
if (TYPE(argv[0]) == T_STRING) { if (TYPE(argv[0]) == T_STRING) {
out = rb_defout; out = rb_defout;
} }
else if (rb_respond_to(argv[0], id_write)) { else {
out = argv[0]; out = argv[0];
argv++; argv++;
argc--; argc--;
} }
else { io_write(out, rb_f_sprintf(argc, argv));
rb_raise(rb_eNameError, "output must responds to `write'");
}
rb_funcall(out, id_write, 1, rb_f_sprintf(argc, argv));
return Qnil; return Qnil;
} }
@ -3151,7 +3147,7 @@ Init_IO()
rb_define_global_function("syscall", rb_f_syscall, -1); rb_define_global_function("syscall", rb_f_syscall, -1);
rb_define_global_function("open", rb_f_open, -1); rb_define_global_function("open", rb_f_open, -1);
rb_define_global_function("printf", rb_rb_f_printf, -1); rb_define_global_function("printf", rb_f_printf, -1);
rb_define_global_function("print", rb_f_print, -1); rb_define_global_function("print", rb_f_print, -1);
rb_define_global_function("putc", rb_f_putc, 1); rb_define_global_function("putc", rb_f_putc, 1);
rb_define_global_function("puts", rb_f_puts, -1); rb_define_global_function("puts", rb_f_puts, -1);

View file

@ -1,4 +1,3 @@
#!/usr/local/bin/ruby
# #
# matrix.rb - # matrix.rb -
# $Release Version: 1.0$ # $Release Version: 1.0$

View file

@ -8,29 +8,7 @@ include Config
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"] SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
$cache_mod = false
$lib_cache = {}
$lib_found = {}
$func_cache = {}
$func_found = {}
$hdr_cache = {}
$hdr_found = {}
$config_cache = CONFIG["compile_dir"]+"/ext/config.cache" $config_cache = CONFIG["compile_dir"]+"/ext/config.cache"
if File.exist?($config_cache) then
f = open($config_cache, "r")
while f.gets
case $_
when /^lib: (.+) (yes|no)/
$lib_cache[$1] = $2
when /^func: ([\w_]+) (yes|no)/
$func_cache[$1] = $2
when /^hdr: (.+) (yes|no)/
$hdr_cache[$1] = $2
end
end
f.close
end
$srcdir = CONFIG["srcdir"] $srcdir = CONFIG["srcdir"]
$libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"] $libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
@ -160,16 +138,6 @@ end
def have_library(lib, func="main") def have_library(lib, func="main")
printf "checking for %s() in -l%s... ", func, lib printf "checking for %s() in -l%s... ", func, lib
STDOUT.flush STDOUT.flush
if $lib_cache[lib]
if $lib_cache[lib] == "yes"
$libs = append_library($libs, lib)
print "(cached) yes\n"
return true
else
print "(cached) no\n"
return false
end
end
if func && func != "" if func && func != ""
libs = append_library($libs, lib) libs = append_library($libs, lib)
@ -195,8 +163,6 @@ int t() { #{func}(); return 0; }
SRC SRC
end end
unless r unless r
$lib_cache[lib] = 'no'
$cache_mod = true
print "no\n" print "no\n"
return false return false
end end
@ -205,8 +171,6 @@ SRC
end end
$libs = libs $libs = libs
$lib_cache[lib] = 'yes'
$cache_mod = true
print "yes\n" print "yes\n"
return true return true
end end
@ -236,16 +200,6 @@ end
def have_func(func) def have_func(func)
printf "checking for %s()... ", func printf "checking for %s()... ", func
STDOUT.flush STDOUT.flush
if $func_cache[func]
if $func_cache[func] == "yes"
$defs.push(format("-DHAVE_%s", func.upcase))
print "(cached) yes\n"
return true
else
print "(cached) no\n"
return false
end
end
libs = $libs libs = $libs
@ -271,14 +225,10 @@ int t() { #{func}(); return 0; }
SRC SRC
end end
unless r unless r
$func_found[func] = 'no'
$cache_mod = true
print "no\n" print "no\n"
return false return false
end end
$defs.push(format("-DHAVE_%s", func.upcase)) $defs.push(format("-DHAVE_%s", func.upcase))
$func_found[func] = 'yes'
$cache_mod = true
print "yes\n" print "yes\n"
return true return true
end end
@ -286,30 +236,15 @@ end
def have_header(header) def have_header(header)
printf "checking for %s... ", header printf "checking for %s... ", header
STDOUT.flush STDOUT.flush
if $hdr_cache[header]
if $hdr_cache[header] == "yes"
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
print "(cached) yes\n"
return true
else
print "(cached) no\n"
return false
end
end
unless try_cpp(<<"SRC") unless try_cpp(<<"SRC")
#include <#{header}> #include <#{header}>
SRC SRC
$hdr_found[header] = 'no'
$cache_mod = true
print "no\n" print "no\n"
return false return false
end end
$hdr_found[header] = 'yes'
header.tr!("a-z./\055", "A-Z___") header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header)) $defs.push(format("-DHAVE_%s", header))
$cache_mod = true
print "yes\n" print "yes\n"
return true return true
end end
@ -493,32 +428,6 @@ EOMF
end end
mfile.close mfile.close
if $cache_mod
begin
f = open($config_cache, "w")
for k,v in $lib_cache
f.printf "lib: %s %s\n", k, v.downcase
end
for k,v in $lib_found
f.printf "lib: %s %s\n", k, v.downcase
end
for k,v in $func_cache
f.printf "func: %s %s\n", k, v.downcase
end
for k,v in $func_found
f.printf "func: %s %s\n", k, v.downcase
end
for k,v in $hdr_cache
f.printf "hdr: %s %s\n", k, v.downcase
end
for k,v in $hdr_found
f.printf "hdr: %s %s\n", k, v.downcase
end
f.close
rescue
end
end
if RUBY_PLATFORM =~ /beos/ if RUBY_PLATFORM =~ /beos/
if RUBY_PLATFORM =~ /^powerpc/ then if RUBY_PLATFORM =~ /^powerpc/ then
deffilename = "ruby.exp" deffilename = "ruby.exp"

View file

@ -27,7 +27,7 @@ module ParseDate
if date.sub!(/(#{DAYPAT})[a-z]*,?/i, ' ') if date.sub!(/(#{DAYPAT})[a-z]*,?/i, ' ')
wday = DAYS[$1.downcase] wday = DAYS[$1.downcase]
end end
if date.sub!(/(\d+):(\d+)(?::(\d+))?\s*(am|pm)?\s*(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4})?|[-+]\d{4}))?/i, ' ') if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4})?|[-+]\d{4}))?/i, ' ')
hour = $1.to_i hour = $1.to_i
min = $2.to_i min = $2.to_i
if $3 if $3
@ -62,6 +62,16 @@ module ParseDate
mday = $1.to_i mday = $1.to_i
mon = MONTHS[$2.downcase] mon = MONTHS[$2.downcase]
year = $3.to_i year = $3.to_i
elsif date.sub!(/(\d+)-(#{MONTHPAT})-(\d+)/i, ' ')
mday = $1.to_i
mon = MONTHS[$2.downcase]
year = $3.to_i
end
p date
if date.sub!(/\d{4}/i, ' ')
year = $&.to_i
elsif date.sub!(/\d\d/i, ' ')
year = $&.to_i
end end
if guess if guess
if year < 100 if year < 100
@ -71,10 +81,6 @@ module ParseDate
year += 2000 year += 2000
end end
end end
elsif date.sub!(/(\d+)-(#{MONTHPAT})-(\d+)/i, ' ')
mday = $1.to_i
mon = MONTHS[$2.downcase]
year = $3.to_i
end end
return year, mon, mday, hour, min, sec, zone, wday return year, mon, mday, hour, min, sec, zone, wday
end end

View file

@ -692,7 +692,8 @@ r_object(arg)
case TYPE_ARRAY: case TYPE_ARRAY:
{ {
volatile int len = r_long(arg); volatile int len = r_long(arg); /* gcc 2.7.2.3 -O2 bug?? */
v = rb_ary_new2(len); v = rb_ary_new2(len);
r_regist(v, arg); r_regist(v, arg);
while (len--) { while (len--) {

View file

@ -694,8 +694,8 @@ An end of a defun is found by moving forward from the beginning of one."
'("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)" '("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
2 font-lock-type-face) 2 font-lock-type-face)
;; functions ;; functions
'("^\\s *def\\s *\\<\\(\\(\\w\\|_\\)+\\(\\.\\|::\\)\\)?\\(\\(\\w\\|_\\)+\\??\\)\\>" '("^\\s *def\\s *\\([^( ]+\\)"
4 font-lock-function-name-face t) 1 font-lock-function-name-face)
;; symbols ;; symbols
'("\\(^\\|[^:]\\)\\(:\\(\\w\\|_\\)+\\??\\)\\b" '("\\(^\\|[^:]\\)\\(:\\(\\w\\|_\\)+\\??\\)\\b"
2 font-lock-reference-face)) 2 font-lock-reference-face))

2
pack.c
View file

@ -798,7 +798,7 @@ pack_pack(ary, fmt)
l = NUM2ULONG(from); l = NUM2ULONG(from);
} }
le = uv_to_utf8(buf, l); le = uv_to_utf8(buf, l);
rb_str_cat(res, (char*)&buf, le); rb_str_cat(res, (char*)buf, le);
} }
break; break;

28
regex.h
View file

@ -1,20 +1,24 @@
/* Definitions for data structures callers pass the regex library. /* Definitions for data structures and routines for the regular
expression library, version 0.12.
Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
Copyright (C) 1985, 1989-90 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
This program is free software; you can redistribute it and/or modify The GNU C Library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Library General Public License as
the Free Software Foundation; either version 1, or (at your option) published by the Free Software Foundation; either version 2 of the
any later version. License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this program; if not, write to the Free Software License along with the GNU C Library; see the file COPYING.LIB. If not,
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) /* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto)
Last change: May 21, 1993 by t^2 */ Last change: May 21, 1993 by t^2 */
/* modified for Ruby by matz@netlab.co.jp */ /* modified for Ruby by matz@netlab.co.jp */

48
ruby.1
View file

@ -25,12 +25,12 @@ ruby - Interpreted object-oriented scripting language
] [ \c ] [ \c
.BI -s \c .BI -s \c
] [ \c ] [ \c
.BI -0 "[digit]"\c .BI -0 "[octal]"\c
] ]
[ \c [ \c
.BI -K "c"\c .BI -K "c"\c
] [ \c ] [ \c
.BI -e "script"\c .BI -e "command"\c
] [ \c ] [ \c
.BI -F "pattern"\c .BI -F "pattern"\c
] ]
@ -39,16 +39,16 @@ ruby - Interpreted object-oriented scripting language
] [ \c ] [ \c
.BI -I "dir"\c .BI -I "dir"\c
] [ \c ] [ \c
.BI -r "filename"\c .BI -r "library"\c
] ]
[ \c [ \c
.BI -S \c .BI -S \c
] [ \c ] [ \c
.BI -v \c .BI -v \c
] [ \c ] [ \c
.BI -x "[dir]"\c .BI -x "[directory]"\c
] [ \c ] [ \c
.BI -X "[dir]"\c .BI -X "directory"\c
] [ \c ] [ \c
.BI -y \c .BI -y \c
] ]
@ -106,9 +106,9 @@ own prototype based object system using singleton methods, if you want
to. to.
.TP .TP
.B "\(bu Mix-in by modules" .B "\(bu Mix-in by modules"
Ruby intentioanlly does not have the multiple inheritance as it is a Ruby intentionally does not have the multiple inheritance as it is a
souce of confusion. Instead, Ruby has the ability to share source of confusion. Instead, Ruby has the ability to share
implementations acrss the inheritance tree. This is oftern called implementations across the inheritance tree. This is often called
`Mix-in'. `Mix-in'.
.TP .TP
.B "\(bu Iterators" .B "\(bu Iterators"
@ -137,8 +137,8 @@ interpreter on-the-fly.
Ruby interpreter accepts following command-line options (switches). Ruby interpreter accepts following command-line options (switches).
They are quite similar to those of Perl. They are quite similar to those of Perl.
.TP .TP
.B -0digit .B -0[octal]
pecifies the input record separator ($/) as an octal number. If no specifies the input record separator ($/) as an octal number. If no
digit is given, the null character is taken as the separator. Other digit is given, the null character is taken as the separator. Other
switches may follow the digits. -00 turns Ruby into paragraph mode. - switches may follow the digits. -00 turns Ruby into paragraph mode. -
0777 makes Ruby read whole file at once as a single string since there 0777 makes Ruby read whole file at once as a single string since there
@ -158,17 +158,17 @@ causes Ruby to check the syntax of the script and exit without
executing. If there are no syntax errors, Ruby will print "Syntax executing. If there are no syntax errors, Ruby will print "Syntax
OK" to the standard output. OK" to the standard output.
.TP .TP
.B -Kc .B --copyright
specifies KANJI (Japanese) code-set. prints the copyright notice.
.TP .TP
.B -d --debug .B -d --debug
turns on debug mode. $DEBUG will set TRUE. turns on debug mode. $DEBUG will set true.
.TP .TP
.B -e script .B -e command
specifies script from command-line while telling Ruby to not specifies script from command-line while telling Ruby to not
search argv for script filenames. search argv for script filenames.
.TP .TP
.B -F regexp .B -F pattern
specifies input field separator ($;). specifies input field separator ($;).
.TP .TP
.B -h --help .B -h --help
@ -194,9 +194,12 @@ example:
used to tell Ruby where to load the library scripts. Directory path used to tell Ruby where to load the library scripts. Directory path
will be added to the load-path variable ($:'). will be added to the load-path variable ($:').
.TP .TP
.B -Kkcode
specifies KANJI (Japanese) code-set.
.TP
.B -l .B -l
enables automatic line-ending processing, which means to firstly set enables automatic line-ending processing, which means to firstly set
$\ to the value of $/, and secondly chops every line read using chop!. $\e to the value of $/, and secondly chops every line read using chop!.
.TP .TP
.B -n .B -n
causes Ruby to assume the following loop around your script, causes Ruby to assume the following loop around your script,
@ -219,8 +222,8 @@ example:
\& MATZ \& MATZ
.fi .fi
.TP .TP
.B -r filename .B -r library
causes Ruby to load the file using [4]require. It is useful causes Ruby to load the library using require. It is useful
with switches -n or -p. with switches -n or -p.
.TP .TP
.B -s .B -s
@ -243,7 +246,7 @@ manner:
.nf .nf
.ne 2 .ne 2
\& #! /usr/local/bin/ruby \& #! /usr/local/bin/ruby
\& # This line makes the next one a comment in ruby \\ \& # This line makes the next one a comment in ruby \e
\& exec /usr/local/bin/ruby -S $0 $* \& exec /usr/local/bin/ruby -S $0 $*
.fi .fi
On some systems $0 does not always contain the full pathname, so you On some systems $0 does not always contain the full pathname, so you
@ -254,10 +257,13 @@ csh.
.TP .TP
.B -v --verbose .B -v --verbose
enables verbose mode. Ruby will print its version at the beginning, enables verbose mode. Ruby will print its version at the beginning,
and set the variable `$VERBOSE' to TRUE. Some methods print extra and set the variable `$VERBOSE' to true. Some methods print extra
messages if this variable is TRUE. If this switch is given, and no messages if this variable is true. If this switch is given, and no
other switches are present, Ruby quits after printing its version. other switches are present, Ruby quits after printing its version.
.TP .TP
.B -T[level]
turns on taint checks at the specified level (default 1).
.TP
.B --version .B --version
prints the version of Ruby interpreter. prints the version of Ruby interpreter.
.TP .TP

10
ruby.c
View file

@ -87,7 +87,7 @@ usage(name)
"-Fpattern split() pattern for autosplit (-a)", "-Fpattern split() pattern for autosplit (-a)",
"-i[extension] edit ARGV files in place (make backup if extension supplied)", "-i[extension] edit ARGV files in place (make backup if extension supplied)",
"-Idirectory specify $LOAD_PATH directory (may be used more than once)", "-Idirectory specify $LOAD_PATH directory (may be used more than once)",
"-K[kcode] specifies KANJI (Japanese) code-set", "-Kkcode specifies KANJI (Japanese) code-set",
"-l enable line ending processing", "-l enable line ending processing",
"-n assume 'while gets; ...; end' loop around your script", "-n assume 'while gets; ...; end' loop around your script",
"-p assume loop like -n but print line also like sed", "-p assume loop like -n but print line also like sed",
@ -98,7 +98,7 @@ usage(name)
"-v enables verbose mode", "-v enables verbose mode",
"-w turn warnings on for compilation of your script", "-w turn warnings on for compilation of your script",
"-x[directory] strip off text before #!ruby line and perhaps cd to directory", "-x[directory] strip off text before #!ruby line and perhaps cd to directory",
"-X[directory] cd to directory, before executing your script", "-Xdirectory cd to directory, before executing your script",
"--copyright print the copyright", "--copyright print the copyright",
"--version print the version", "--version print the version",
"\n", "\n",
@ -604,12 +604,6 @@ load_file(fname, script)
xflag = Qfalse; xflag = Qfalse;
while (!NIL_P(line = rb_io_gets(f))) { while (!NIL_P(line = rb_io_gets(f))) {
line_start++; line_start++;
#if defined(__EMX__) || defined(OS2)
/*
if (p = strstr(RSTRING(line)->ptr, "extproc"))
line = io_gets(f);
*/
#endif /* __EMX__ */
if (RSTRING(line)->len > 2 if (RSTRING(line)->len > 2
&& RSTRING(line)->ptr[0] == '#' && RSTRING(line)->ptr[0] == '#'
&& RSTRING(line)->ptr[1] == '!') { && RSTRING(line)->ptr[1] == '!') {

View file

@ -32,3 +32,4 @@ error = ''
end end
print error print error
print "test failed\n" print "test failed\n"
exit 1

View file

@ -80,7 +80,7 @@ OBJS = array.obj \
version.obj \ version.obj \
$(MISSING) $(MISSING)
all: miniruby$(EXEEXT) rbconfig.rb ext/extmk.rb ext/Setup.nt rubymw.lib $(MISCLIBS) all: miniruby$(EXEEXT) rbconfig.rb ext/extmk.rb ext/Setup rubymw.lib $(MISCLIBS)
set LIB=..\..\win32;$(ORGLIBPATH) set LIB=..\..\win32;$(ORGLIBPATH)
@.\miniruby$(EXEEXT) -Xext extmk.rb @.\miniruby$(EXEEXT) -Xext extmk.rb
@ -248,7 +248,7 @@ file.obj: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
gc.obj: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h gc.obj: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
hash.obj: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h hash.obj: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h
inits.obj: inits.c ruby.h config.h defines.h intern.h inits.obj: inits.c ruby.h config.h defines.h intern.h
io.obj: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h io.obj: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h env.h
main.obj: main.c ruby.h config.h defines.h intern.h main.obj: main.c ruby.h config.h defines.h intern.h
marshal.obj: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h marshal.obj: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
prec.obj: prec.c ruby.h config.h defines.h intern.h prec.obj: prec.c ruby.h config.h defines.h intern.h

View file

@ -41,6 +41,8 @@
#define DLEXT ".dll" #define DLEXT ".dll"
#define RUBY_LIB "/usr/local/lib/ruby/1.4" #define RUBY_LIB "/usr/local/lib/ruby/1.4"
#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.4/i386-mswin32" #define RUBY_ARCHLIB "/usr/local/lib/ruby/1.4/i386-mswin32"
#define RUBY_SITE_LIB "/usr/local/lib/ruby/1.4/site_ruby"
#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/1.4/site_ruby/i386-mswin32"
#define RUBY_PLATFORM "i386-mswin32" #define RUBY_PLATFORM "i386-mswin32"
#define SIZEOF_INT 4 #define SIZEOF_INT 4

View file

@ -48,7 +48,7 @@ s%@LDSHARED@%cl -LD%g
s%@DLEXT@%dll%g s%@DLEXT@%dll%g
s%@STRIP@%%g s%@STRIP@%%g
s%@EXTSTATIC@%%g s%@EXTSTATIC@%%g
s%@setup@%Setup.nt%g s%@setup@%Setup
s%@LIBRUBY_LDSHARED@%%g s%@LIBRUBY_LDSHARED@%%g
s%@LIBRUBY_DLDFLAGS@%%g s%@LIBRUBY_DLDFLAGS@%%g
s%@RUBY_INSTALL_NAME@%ruby%g s%@RUBY_INSTALL_NAME@%ruby%g

View file

@ -279,6 +279,7 @@ EXPORTS
rb_apply rb_apply
rb_funcall rb_funcall
rb_funcall2 rb_funcall2
rb_funcall3
rb_backtrace rb_backtrace
rb_frame_last_func rb_frame_last_func
rb_obj_instance_eval rb_obj_instance_eval