summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README48
-rw-r--r--README.ja.md115
-rw-r--r--README.md107
-rw-r--r--include/mrbconf.h9
-rw-r--r--include/mruby.h56
-rw-r--r--include/mruby/data.h (renamed from src/mdata.h)2
-rw-r--r--src/Makefile2
-rw-r--r--src/array.c1
-rw-r--r--src/encoding.h2
-rw-r--r--src/etc.c1
-rw-r--r--src/gc.c6
-rw-r--r--src/kernel.c1
-rw-r--r--src/numeric.c173
-rw-r--r--src/object.c1
-rw-r--r--src/re.c49
-rw-r--r--src/regint.h4
-rw-r--r--src/st.h6
-rw-r--r--src/string.c183
-rw-r--r--src/transcode.c8
-rw-r--r--src/variable.h1
-rw-r--r--tools/mruby/mruby.c6
21 files changed, 281 insertions, 500 deletions
diff --git a/README b/README
index e9a7523d4..12f8f5135 100644
--- a/README
+++ b/README
@@ -1,14 +1,15 @@
-!!Notice!! This is a preliminary release for internal team reviewing.
- The URL and address discribed below are not available yet.
- The official release will be announced later. Thanks.
- Any suggestion of the modification are welcome,
- but the response might be delayed. Sorry for that in advance.
+!!Notice!!
+ This is a preliminary release for internal team reviewing.
+ The URL and address discribed below are not available yet.
+ The official release will be announced later. Thanks.
+ Any suggestion of the modification are welcome,
+ but the response might be delayed. Sorry for that in advance.
* What's mruby
-mruby is the light-weight implementation of the Ruby language complied to the ISO
-standard to execute various environments. It can run in 'interpreter form' or
-'compile and execute on vm form' according to its module construction.
+mruby is the light-weight implementation of the Ruby language complied to
+the ISO standard to execute various environments. It can run in 'interpreter
+form' or 'compile and execute on vm form' according to its module construction.
This achievement is due to the Regional Innovation Creation R&D Programs of
the Ministry of Economy, Trade and Industry of Japan.
@@ -16,18 +17,18 @@ the Ministry of Economy, Trade and Industry of Japan.
* Features of mruby
-|FIXME:
-| + Simple Syntax
-| + *Normal* Object-Oriented features(ex. class, method calls)
-| + *Advanced* Object-Oriented features(ex. Mix-in, Singleton-method)
-| + Operator Overloading
-| + Exception Handling
-| + Iterators and Closures
-| + Garbage Collection
-| + Dynamic Loading of Object files(on some architecture)
-| + Highly Portable (works on many Unix-like/POSIX compatible platforms
-| as well as Windows, Mac OS X, BeOS etc.)
-| cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatforms
+ |FIXME:
+ | + Simple Syntax
+ | + *Normal* Object-Oriented features(ex. class, method calls)
+ | + *Advanced* Object-Oriented features(ex. Mix-in, Singleton-method)
+ | + Operator Overloading
+ | + Exception Handling
+ | + Iterators and Closures
+ | + Garbage Collection
+ | + Dynamic Loading of Object files(on some architecture)
+ | + Highly Portable (works on many Unix-like/POSIX compatible platforms
+ | as well as Windows, Mac OS X, BeOS etc.)
+ | cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatforms
* How to get mruby
@@ -39,19 +40,19 @@ The mruby distribution files can be found in the following site:
The trunk of the mruby source tree can be checked out with the
following command:
- $ git ....
+ $ git ....
There are some other branches under development. Try the following
command and see the list of branches:
- $ git ....
+ $ git ....
* mruby home-page (sorry, it's not launched yet. we're working on this)
The URL of the mruby home-page is:
- http://www.mruby.org/
+ http://www.mruby.org/
* Mailing list
@@ -59,6 +60,7 @@ The URL of the mruby home-page is:
There is a mailing list to talk about mruby.
To subscribe this list....[T.B.D.]
+
* How to compile and install
See the file INSTALL.
diff --git a/README.ja.md b/README.ja.md
new file mode 100644
index 000000000..0776226aa
--- /dev/null
+++ b/README.ja.md
@@ -0,0 +1,115 @@
+# !!ご注意!!
+ これはチーム内レビューの為の事前公開です。
+ 記述されているURLやメールアドレスは現在使用できません。
+ 正式リリースは後日アナウンス予定です。
+
+ 修正のご指摘は随時受け付けていますが、対応が遅れる可能性があります。
+ 予めご了承ください。
+
+## mrubyとは
+
+mrubyは[ISO規格](http://www.ipa.go.jp/about/press/20120402_2.html)に準拠したRuby言語を様々な環境で動作可能となるように
+軽量化したものです。モジュール構成によりインタプリタ実行形式や
+コンパイル&VM実行形式でも動作させることができます。
+
+2010年度の経済産業省の地域イノベーション創出事業により開発されました。
+
+
+## mrubyの特長
+
+ |MRI(Matz Ruby Implementation)版との互換性
+ |
+ |以下要修正
+ | + シンプルな文法
+ | + 普通のオブジェクト指向機能(クラス,メソッドコールなど)
+ | + 特殊なオブジェクト指向機能(Mixin, 特異メソッドなど)
+ | + 演算子オーバーロード
+ | + 例外処理機能
+ | + イテレータとクロージャ
+ | + ガーベージコレクタ
+ | + ダイナミックローディング (アーキテクチャによる)
+ | + 移植性が高い.多くのUnix-like/POSIX互換プラットフォーム上で
+ | 動くだけでなく,Windows, Mac OS X,BeOSなどの上でも動く
+ | cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatformsJa
+
+
+## 入手法
+
+### Zipで
+
+以下の場所においてあります。
+
+ https://github.com/mruby/mruby/zipball/master
+
+### GitHubで
+
+開発先端のソースコードは次のコマンドで取得できます。
+
+ $ git ....
+
+他に開発中のブランチの一覧は次のコマンドで見られます。
+
+ $ git ....
+
+
+## ホームページ
+
+まだ準備中です。ただいま鋭意製作中です。
+
+mrubyのホームページのURLは
+
+ http://www.mruby.org/
+
+になる予定です。
+
+
+## メーリングリスト
+
+mrubyのメーリングリストがあります。参加希望の方は....[T.B.D.]
+
+
+mruby開発者向けメーリングリストもあります。こちらではrubyのバグ、
+将来の仕様拡張など実装上の問題について議論されています。
+参加希望の方は....[T.B.D.]
+
+
+## コンパイル・インストール・移植
+
+INSTALL.ja ファイルを参照してください。
+
+
+## 配布条件
+
+COPYING.ja ファイルを参照してください。
+
+
+## コントリビュートについて
+
+mrubyへの貢献の検討をありがとうございます。
+mrubyは組込み機器などの様々な環境で利用させることを期待し、ライセンスを
+比較的制限の緩いMITライセンスにすることにいたしました。
+しかしながら、ライセンスの実行条件としてマニュアル等の何らかの形で
+著作権表記及びライセンス文を記述する必要があります。
+昨今の規模の大きくなったシステムではこれらの対応も相当の煩雑さを伴います。
+そこで、mrubyではできる限り表記を簡便にするために、便宜上、著作権者名を
+"mruby developers"とすることにいたしました。
+今後、新たにmrubyへのコミットされるコードについては、著作権を保持したまま、
+"mruby developers"の一員としてMITライセンスでの配布をお願いしたいと
+考えています。
+(コミットしたコードの著作権を譲渡や放棄をお願いするものではありません。
+ 実質の著作者名はAUTHORSファイルに表記いたします。)
+
+尚、その他のライセンスでの配布やGPL由来のコードのコミットについては
+別途ご相談ください。
+
+
+## 著者
+
+AUTHORS ファイルを参照してください。
+
+
+コメント,バグレポートその他は
+
+
+まで。
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..8fcbf44c7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,107 @@
+# !!Notice!!
+ This is a preliminary release for internal team review.
+ The URLs and addresses described below are not available yet.
+ The official release will be announced later.
+ Any suggestion for modification is welcome.
+ Delays in replies are to be expected. Sorry in advance.
+
+## What's mruby
+
+mruby is the lightweight implementation of the Ruby language complying to
+the [ISO standard](http://www.ipa.go.jp/about/press/20120402_2.html).
+mruby can run Ruby code in 'interpreter mode' or 'compile and execute it on a virtual machine' depending on how the developer's preference.
+
+This achievement was sponsored by the Regional Innovation Creation R&D Programs of
+the Ministry of Economy, Trade and Industry of Japan.
+
+
+## Features of mruby
+
+ | Compatibility with MRI(Matz Ruby Implementation) version...
+ |
+ |FIXME:
+ | + Simple Syntax
+ | + *Normal* Object-Oriented features(ex. class, method calls)
+ | + *Advanced* Object-Oriented features(ex. Mixin, Singleton-method)
+ | + Operator Overloading
+ | + Exception Handling
+ | + Iterators and Closures
+ | + Garbage Collection
+ | + Dynamic Loading of Object files(on some architecture)
+ | + Highly Portable (works on many Unix-like/POSIX compatible platforms
+ | as well as Windows, Mac OS X, BeOS etc.)
+ | cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatforms
+
+
+## How to get mruby
+
+The mruby distribution files can be found in the following site:
+
+ https://github.com/mruby/mruby/zipball/master
+
+The trunk of the mruby source tree can be checked out with the
+following command:
+
+ $ git clone https://github.com/mruby/mruby.git
+
+There are some other branches under development. Try the following
+command and see the list of branches:
+
+ $ git ....
+
+
+## mruby home-page
+
+mruby's website is not launched yet but we are actively working on it.
+
+The URL of the mruby home-page will be:
+
+ http://www.mruby.org/
+
+
+## Mailing list
+
+To subscribe the mruby mailing list....[T.B.D.]
+
+
+## How to compile and install
+
+See the INSTALL file.
+
+
+## Copying
+
+See the COPYING file.
+
+
+## About Contribution
+
+Thank you for considering contributing to mruby.
+mruby has chosen a MIT License due to its permissive license allowing
+developer to target various environments such as embedded systems.
+However, the license requires to display the copyright notice and license
+information in manuals for instance. Doing so for big projects can be
+complicated or troublesome.
+This is why, mruby has decided to display "mruby developers" as copyright name
+to make it simple conventionally.
+In the future, mruby might ask you to distribute your new codes
+(that you will commit,) under MIT License as a member of
+"mruby developers" but contributors will keep their copyright.
+(We did not intend for contributors to transfer or waive their copyrights,
+ Actual copyright holder name (contributors) will be listed in the AUTHORS file.)
+
+Please ask us if you want to distribute your code under other license
+or if your code is derived from GPL code.
+
+
+## The Author
+
+See the file AUTHORS.
+
+
+Feel free to send comments and bug reports to the author. Here is the
+author's latest mail address:
+
+
+
diff --git a/include/mrbconf.h b/include/mrbconf.h
index d4802a5e7..923558fd9 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -22,15 +22,6 @@ typedef intptr_t mrb_sym;
#undef HAVE_UNISTD_H /* WINDOWS */
#define HAVE_UNISTD_H /* LINUX */
-#define SIZEOF_INT 4
-#define SIZEOF_SHORT 2
-#define SIZEOF_LONG 4
-#define SIZEOF_LONG_LONG 8
-#define SIZEOF___INT64 0
-#define SIZEOF_VOIDP 4
-#define SIZEOF_FLOAT 4
-#define SIZEOF_DOUBLE 8
-
#ifndef FALSE
# define FALSE 0
#endif
diff --git a/include/mruby.h b/include/mruby.h
index 397885ac5..bea125dd4 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -134,7 +134,7 @@ static inline mrb_value
mrb_obj_value(void *p)
{
mrb_value v;
- struct RBasic *b = p;
+ struct RBasic *b = (struct RBasic*) p;
v.tt = b->tt;
v.value.p = p;
@@ -560,60 +560,6 @@ void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
#define ruby_setjmp(env) RUBY_SETJMP(env)
#define ruby_longjmp(env,val) RUBY_LONGJMP(env,val)
-#if defined PRIdPTR && !defined PRI_VALUE_PREFIX
-#define PRIdVALUE PRIdPTR
-#define PRIiVALUE PRIiPTR
-#define PRIoVALUE PRIoPTR
-#define PRIuVALUE PRIuPTR
-#define PRIxVALUE PRIxPTR
-#define PRIXVALUE PRIXPTR
-#else
-#define PRIdVALUE PRI_VALUE_PREFIX"d"
-#define PRIiVALUE PRI_VALUE_PREFIX"i"
-#define PRIoVALUE PRI_VALUE_PREFIX"o"
-#define PRIuVALUE PRI_VALUE_PREFIX"u"
-#define PRIxVALUE PRI_VALUE_PREFIX"x"
-#define PRIXVALUE PRI_VALUE_PREFIX"X"
-#endif
-#ifndef PRI_VALUE_PREFIX
-# define PRI_VALUE_PREFIX ""
-#endif
-
-#if defined PRIdPTR
-# define PRI_PTRDIFF_PREFIX "t"
-#elif SIZEOF_PTRDIFF_T == SIZEOF_INT
-# define PRI_PTRDIFF_PREFIX
-#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
-# define PRI_PTRDIFF_PREFIX "l"
-#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
-# define PRI_PTRDIFF_PREFIX "ll"
-#else
-# define PRI_PTRDIFF_PREFIX
-#endif
-#define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
-#define PRIiPTRDIFF PRI_PTRDIFF_PREFIX"i"
-#define PRIoPTRDIFF PRI_PTRDIFF_PREFIX"o"
-#define PRIuPTRDIFF PRI_PTRDIFF_PREFIX"u"
-#define PRIxPTRDIFF PRI_PTRDIFF_PREFIX"x"
-#define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X"
-
-#if defined PRIdPTR
-# define PRI_SIZE_PREFIX "z"
-#elif SIZEOF_SIZE_T == SIZEOF_INT
-# define PRI_SIZE_PREFIX
-#elif SIZEOF_SIZE_T == SIZEOF_LONG
-# define PRI_SIZE_PREFIX "l"
-#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
-# define PRI_SIZE_PREFIX "ll"
-#endif
-#define PRIdSIZE PRI_SIZE_PREFIX"d"
-#define PRIiSIZE PRI_SIZE_PREFIX"i"
-#define PRIoSIZE PRI_SIZE_PREFIX"o"
-#define PRIuSIZE PRI_SIZE_PREFIX"u"
-#define PRIxSIZE PRI_SIZE_PREFIX"x"
-#define PRIXSIZE PRI_SIZE_PREFIX"X"
-#define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
-
#define KHASH 0
#define STHASH 1
#define BASICHASH 2
diff --git a/src/mdata.h b/include/mruby/data.h
index 827f7c114..07e0f72cd 100644
--- a/src/mdata.h
+++ b/include/mruby/data.h
@@ -1,6 +1,6 @@
/**********************************************************************
- mdata.h -
+ data.h -
Copyright (C) 2007 Yukihiro Matsumoto
diff --git a/src/Makefile b/src/Makefile
index ea3681dce..abb6f4c4b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -40,7 +40,7 @@ YACC = bison
DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1)
-CFLAGS = -g
+CFLAGS = -g -O3
else
CFLAGS = -O3
endif
diff --git a/src/array.c b/src/array.c
index 855a45aba..69f5fd8b3 100644
--- a/src/array.c
+++ b/src/array.c
@@ -2,7 +2,6 @@
#include "mruby/array.h"
#include <string.h>
#include "mruby/string.h"
-#include "mdata.h"
#include "mruby/class.h"
#ifdef INCLUDE_REGEXP
diff --git a/src/encoding.h b/src/encoding.h
index 784d67f44..92e16e5f2 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -18,7 +18,7 @@ extern "C" {
#include <stdarg.h>
#include "oniguruma.h"
-#include "mdata.h"
+#include "mruby/data.h"
int mrb_tolower(int c);
int mrb_toupper(int c);
diff --git a/src/etc.c b/src/etc.c
index 8c98700a3..865992566 100644
--- a/src/etc.c
+++ b/src/etc.c
@@ -1,5 +1,4 @@
#include "mruby.h"
-#include "mdata.h"
#include "mruby/string.h"
#include "error.h"
#include "mruby/numeric.h"
diff --git a/src/gc.c b/src/gc.c
index e4b1f82ba..ad5bcc7a8 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "mruby/struct.h"
#include "mruby/proc.h"
-#include "mdata.h"
+#include "mruby/data.h"
#include "mruby/numeric.h"
/*
@@ -401,8 +401,8 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
struct REnv *e = (struct REnv *)obj;
if (e->cioff < 0) {
- mrb_free(mrb, mrb->stack);
- mrb->stack = 0;
+ mrb_free(mrb, e->stack);
+ e->stack = 0;
}
}
break;
diff --git a/src/kernel.c b/src/kernel.c
index e5b2cab04..7a4a13501 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -14,7 +14,6 @@
#include "ritehash.h"
#include "error.h"
#include "method.h"
-#include "mdata.h"
#ifdef INCLUDE_REGEXP
#include "re.h"
diff --git a/src/numeric.c b/src/numeric.c
index f79369d90..135691644 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -88,34 +88,9 @@
#define mrb_rational_raw1(x) mrb_rational_raw(x, INT2FIX(1))
-#if SIZEOF_LONG_LONG > 0
-# define LONG_LONG long long
-#elif SIZEOF___INT64 > 0
-# define HAVE_LONG_LONG 1
-# define LONG_LONG __int64
-# undef SIZEOF_LONG_LONG
-# define SIZEOF_LONG_LONG SIZEOF___INT64
-#endif
-
-#if defined HAVE_UINTPTR_T && 0
typedef uintptr_t VALUE;
typedef uintptr_t ID;
-# define SIGNED_VALUE intptr_t
-# define SIZEOF_VALUE SIZEOF_UINTPTR_T
-#elif SIZEOF_LONG == SIZEOF_VOIDP
-//typedef unsigned long VALUE;
-//typedef unsigned long ID;
-# define SIGNED_VALUE long long
-# define SIZEOF_VALUE SIZEOF_LONG
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-typedef unsigned LONG_LONG VALUE;
-typedef unsigned LONG_LONG ID;
-# define SIGNED_VALUE LONG_LONG
-# define LONG_LONG_VALUE 1
-# define SIZEOF_VALUE SIZEOF_LONG_LONG
-#else
-# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
-#endif
+#define SIGNED_VALUE intptr_t
#ifdef HAVE_INFINITY
#elif BYTE_ORDER == LITTLE_ENDIAN
@@ -980,80 +955,6 @@ mrb_num2ulong(mrb_state *mrb, mrb_value val)
}
}
-#if SIZEOF_INT < SIZEOF_VALUE
-void
-mrb_out_of_int(mrb_state *mrb, SIGNED_VALUE num)
-{
- mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIdVALUE " too %s to convert to `int'",
- num, num < 0 ? "small" : "big");
-}
-
-static void
-check_int(SIGNED_VALUE num)
-{
- if ((SIGNED_VALUE)(int)num != num) {
- mrb_out_of_int(num);
- }
-}
-
-static void
-check_uint(mrb_state *mrb, mrb_value num, mrb_value sign)
-{
- static const mrb_value mask = ~(mrb_value)UINT_MAX;
-
- if (RTEST(sign)) {
- /* minus */
- if ((num & mask) != mask || (num & ~mask) <= INT_MAX + 1UL)
- mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIdVALUE " too small to convert to `unsigned int'", num);
- }
- else {
- /* plus */
- if ((num & mask) != 0)
- mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIuVALUE " too big to convert to `unsigned int'", num);
- }
-}
-
-long
-mrb_num2int(mrb_value val)
-{
- long num = mrb_num2long(mrb, val);
-
- check_int(num);
- return num;
-}
-
-long
-mrb_fix2int(mrb_state *mrb, mrb_value val)
-{
- long num = FIXNUM_P(val)?mrb_fixnum(val):mrb_num2long(mrb, val);
-
- check_int(num);
- return num;
-}
-
-unsigned long
-mrb_num2uint(mrb_value val)
-{
- unsigned long num = mrb_num2ulong(val);
-
- check_uint(num, mrb_funcall(mrb, val, "<", 1, mrb_fixnum_value(0)));
- return num;
-}
-
-unsigned long
-mrb_fix2uint(mrb_state *mrb, mrb_value val)
-{
- unsigned long num;
-
- if (!FIXNUM_P(val)) {
- return mrb_num2uint(mrb, val);
- }
- num = FIX2ULONG(val);
-
- check_uint(num, mrb_funcall(mrb, val, "<", 1, mrb_fixnum_value(0)));
- return num;
-}
-#else
long
mrb_num2int(mrb_state *mrb, mrb_value val)
{
@@ -1065,7 +966,6 @@ mrb_fix2int(mrb_value val)
{
return mrb_fixnum(val);
}
-#endif
mrb_value
mrb_num2fix(mrb_state *mrb, mrb_value val)
@@ -1076,59 +976,10 @@ mrb_num2fix(mrb_state *mrb, mrb_value val)
v = mrb_num2long(mrb, val);
if (!FIXABLE(v))
- mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIdVALUE " out of range of fixnum", v);
+ mrb_raise(mrb, E_RANGE_ERROR, "integer %ld out of range of fixnum", v);
return mrb_fixnum_value(v);
}
-#if HAVE_LONG_LONG
-
-LONG_LONG
-mrb_num2ll(mrb_state *mrb, mrb_value val)
-{
- if (mrb_nil_p(val)) {
- mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion from nil");
- }
-
- if (FIXNUM_P(val)) return (LONG_LONG)mrb_fixnum(val);
-
- switch (mrb_type(val)) {
- case MRB_TT_FLOAT:
- if (mrb_float(val) <= (double)LLONG_MAX
- && mrb_float(val) >= (double)LLONG_MIN) {
- return (LONG_LONG)(mrb_float(val));
- }
- else {
- char buf[24];
- char *s;
-
- snprintf(buf, sizeof(buf), "%-.10g", mrb_float(val));
- if ((s = strchr(buf, ' ')) != 0) *s = '\0';
- mrb_raise(mrb, E_RANGE_ERROR, "float %s out of range of long long", buf);
- }
-
- case MRB_TT_STRING:
- mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion from string");
- return mrb_nil_value(); /* not reached */
-
- case MRB_TT_TRUE:
- case MRB_TT_FALSE:
- mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion from boolean");
- return mrb_nil_value(); /* not reached */
-
- default:
- val = mrb_to_int(mrb, val);
- return NUM2LL(val);
- }
-}
-
-unsigned LONG_LONG
-mrb_num2ull(mrb_state *mrb, mrb_value val)
-{
- return (unsigned LONG_LONG)mrb_num2ll(mrb, val);
-}
-
-#endif /* HAVE_LONG_LONG */
-
/*
* Document-class: Integer
*
@@ -1204,7 +1055,7 @@ mrb_value
rb_fix2str(mrb_state *mrb, mrb_value x, int base)
{
extern const char ruby_digitmap[];
- char buf[SIZEOF_VALUE*CHAR_BIT + 2], *b = buf + sizeof buf;
+ char buf[sizeof(mrb_int)*CHAR_BIT + 2], *b = buf + sizeof buf;
long val = mrb_fixnum(x);
int neg = 0;
@@ -1229,7 +1080,7 @@ rb_fix2str(mrb_state *mrb, mrb_value x, int base)
return mrb_usascii_str_new2(mrb, b);
}
-#define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
+#define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((sizeof(intptr_t)*CHAR_BIT-1)/2))
/*tests if N*N would overflow*/
#define FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))
@@ -1255,21 +1106,12 @@ fix_mul(mrb_state *mrb, mrb_value x)
volatile
#endif
long a, b;
-#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
- LONG_LONG d;
-#else
long c;
mrb_value r;
-#endif
a = mrb_fixnum(x);
b = mrb_fixnum(y);
-#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
- d = (LONG_LONG)a * b;
- if (FIXABLE(d)) return mrb_fixnum_value(d);
- return mrb_nil_value();// rb_ll2inum(d);
-#else
if (FIT_SQRT_LONG(a) && FIT_SQRT_LONG(b))
return mrb_fixnum_value(a*b);
c = a * b;
@@ -1281,7 +1123,6 @@ fix_mul(mrb_state *mrb, mrb_value x)
r = mrb_fixnum_value(a*b);
}
return r;
-#endif
}
switch (mrb_type(y)) {
case MRB_TT_FLOAT:
@@ -1615,9 +1456,9 @@ mrb_fix_lshift(mrb_state *mrb, mrb_value x)
static mrb_value
fix_lshift(mrb_state *mrb, long val, unsigned long width)
{
- if (width > (SIZEOF_LONG*CHAR_BIT-1)
- || ((unsigned long)abs(val))>>(SIZEOF_LONG*CHAR_BIT-1-width) > 0) {
- mrb_raise(mrb, E_RANGE_ERROR, "width(%d) > (SIZEOF_LONG*CHAR_BIT-1)", width);
+ if (width > (sizeof(intptr_t)*CHAR_BIT-1)
+ || ((unsigned long)abs(val))>>(sizeof(intptr_t)*CHAR_BIT-1-width) > 0) {
+ mrb_raise(mrb, E_RANGE_ERROR, "width(%d) > (sizeof(intptr_t)*CHAR_BIT-1)", width);
}
val = val << width;
return mrb_fixnum_value(val);
diff --git a/src/object.c b/src/object.c
index c60c2fb7b..0a31fa108 100644
--- a/src/object.c
+++ b/src/object.c
@@ -5,7 +5,6 @@
#include "mruby/class.h"
#include "method.h"
#include "mruby/numeric.h"
-#include "mdata.h"
#ifdef INCLUDE_REGEXP
#define mrb_usascii_str_new2 mrb_usascii_str_new_cstr
diff --git a/src/re.c b/src/re.c
index 645af6ba6..0cdf58e7a 100644
--- a/src/re.c
+++ b/src/re.c
@@ -1773,11 +1773,7 @@ static int
pair_byte_cmp(const void *pair1, const void *pair2)
{
long diff = ((pair_t*)pair1)->byte_pos - ((pair_t*)pair2)->byte_pos;
-#if SIZEOF_LONG > SIZEOF_INT
return diff ? diff > 0 ? 1 : -1 : 0;
-#else
- return (int)diff;
-#endif
}
static void
@@ -2959,48 +2955,6 @@ mrb_backref_set(mrb_state *mrb, mrb_value val)
#ifdef INCLUDE_ENCODING
static inline long
-mrb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
-{
- const unsigned char *x = xs, *xe = xs + m;
- const unsigned char *y = ys, *ye = ys + n;
-#define SIZEOF_VOIDP 4
-#define SIZEOF_LONG 4
-
-#ifndef VALUE_MAX
-# if SIZEOF_VALUE == 8
-# define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL
-# elif SIZEOF_VALUE == 4
-# define VALUE_MAX 0xFFFFFFFFUL
-# elif SIZEOF_LONG == SIZEOF_VOIDP
-# define SIZEOF_VALUE 4
-# define VALUE_MAX 0xFFFFFFFFUL
-# endif
-#endif
- int hx, hy, mask = VALUE_MAX >> ((SIZEOF_VALUE - m) * CHAR_BIT);
-
- if (m > SIZEOF_VALUE)
- mrb_bug("!!too long pattern string!!");
-
- /* Prepare hash value */
- for (hx = *x++, hy = *y++; x < xe; ++x, ++y) {
- hx <<= CHAR_BIT;
- hy <<= CHAR_BIT;
- hx |= *x;
- hy |= *y;
- }
- /* Searching */
- while (hx != hy) {
- if (y == ye)
- return -1;
- hy <<= CHAR_BIT;
- hy |= *y;
- hy &= mask;
- y++;
- }
- return y - ys - m;
-}
-
-static inline long
mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
{
const unsigned char *x = xs, *xe = xs + m;
@@ -3094,9 +3048,6 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_
}
return -1;
}
- else if (m <= SIZEOF_VALUE) {
- return mrb_memsearch_ss(x0, m, y0, n);
- }
else if (enc == mrb_utf8_encoding(mrb)) {
return mrb_memsearch_qs_utf8(x0, m, y0, n);
}
diff --git a/src/regint.h b/src/regint.h
index e86a95f27..bf19eee1a 100644
--- a/src/regint.h
+++ b/src/regint.h
@@ -246,11 +246,11 @@
} while(0)
/* sizeof(OnigCodePoint) */
-#define WORD_ALIGNMENT_SIZE SIZEOF_LONG
+#define WORD_ALIGNMENT_SIZE sizeof(uintptr_t)
#define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
(pad_size) = WORD_ALIGNMENT_SIZE \
- - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
+ - ((uintptr_t)(addr) % WORD_ALIGNMENT_SIZE);\
if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
} while (0)
diff --git a/src/st.h b/src/st.h
index 7324e8da7..d7ec7eb38 100644
--- a/src/st.h
+++ b/src/st.h
@@ -64,12 +64,6 @@ struct st_table_entry {
st_table_entry *fore, *back;
};
-#ifndef SIZEOF_VOIDP
-#define SIZEOF_VOIDP 4
-#endif
-
-#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
-
struct st_hash_type {
int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
diff --git a/src/string.c b/src/string.c
index da52172f7..6b8861ace 100644
--- a/src/string.c
+++ b/src/string.c
@@ -211,38 +211,12 @@ single_byte_optimizable(mrb_state *mrb, mrb_value str)
static inline const char *
search_nonascii(const char *p, const char *e)
{
-#if SIZEOF_VALUE == 8
-# define NONASCII_MASK 0x8080808080808080ULL
-#elif SIZEOF_VALUE == 4
-# define NONASCII_MASK 0x80808080UL
-#endif
-#ifdef NONASCII_MASK
- if ((int)sizeof(intptr_t) * 2 < e - p) {
- const intptr_t *s, *t;
- const intptr_t lowbits = sizeof(intptr_t) - 1;
- s = (const intptr_t*)(~lowbits & ((intptr_t)p + lowbits));
- while (p < (const char *)s) {
- if (!ISASCII(*p))
- return p;
- p++;
- }
- t = (const intptr_t*)(~lowbits & (intptr_t)e);
- while (s < t) {
- if (*s & (intptr_t)NONASCII_MASK) {
- t = s;
- break;
- }
- s++;
- }
- p = (const char *)t;
- }
-#endif
- while (p < e) {
- if (!ISASCII(*p))
- return p;
- p++;
- }
- return NULL;
+ while (p < e) {
+ if (!ISASCII(*p))
+ return p;
+ p++;
+ }
+ return NULL;
}
#endif //INCLUDE_ENCODING
@@ -1167,63 +1141,6 @@ mrb_str_match(mrb_state *mrb, mrb_value self/* x */)
}
}
/* ---------------------------------- */
-#ifdef INCLUDE_ENCODING
-#ifdef NONASCII_MASK
-#define is_utf8_lead_byte(c) (((c)&0xC0) != 0x80)
-static inline int
-count_utf8_lead_bytes_with_word(const intptr_t *s)
-{
- int d = *s;
- d |= ~(d>>1);
- d >>= 6;
- d &= NONASCII_MASK >> 7;
- d += (d>>8);
- d += (d>>16);
-#if SIZEOF_VALUE == 8
- d += (d>>32);
-#endif
- return (d&0xF);
-}
-#endif
-
-#ifdef NONASCII_MASK
-static char *
-str_utf8_nth(const char *p, const char *e, long nth)
-{
- if ((int)SIZEOF_VALUE < e - p && (int)SIZEOF_VALUE * 2 < nth) {
- const intptr_t *s, *t;
- const intptr_t lowbits = sizeof(int) - 1;
- s = (const intptr_t*)(~lowbits & ((intptr_t)p + lowbits));
- t = (const intptr_t*)(~lowbits & (intptr_t)e);
- while (p < (const char *)s) {
- if (is_utf8_lead_byte(*p)) nth--;
- p++;
- }
- do {
- nth -= count_utf8_lead_bytes_with_word(s);
- s++;
- } while (s < t && (int)sizeof(intptr_t) <= nth);
- p = (char *)s;
- }
- while (p < e) {
- if (is_utf8_lead_byte(*p)) {
- if (nth == 0) break;
- nth--;
- }
- p++;
- }
- return (char *)p;
-}
-
-static long
-str_utf8_offset(const char *p, const char *e, long nth)
-{
- const char *pp = str_utf8_nth(p, e, nth);
- return pp - p;
-}
-#endif
-#endif //INCLUDE_ENCODING
-
mrb_value
mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, int len)
{
@@ -1283,13 +1200,6 @@ mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, int len)
if (len == 0) {
p = 0;
}
-#ifdef NONASCII_MASK
- else if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
- enc == mrb_utf8_encoding(mrb)) {
- p = str_utf8_nth(s, e, beg);
- len = str_utf8_offset(p, e, len);
- }
-#endif
else if (mrb_enc_mbmaxlen(enc) == mrb_enc_mbminlen(enc)) {
int char_sz = mrb_enc_mbmaxlen(enc);
@@ -1406,46 +1316,6 @@ mrb_enc_strlen_cr(mrb_state *mrb, const char *p, const char *e, mrb_encoding *en
#ifndef INCLUDE_ENCODING
static inline long
-mrb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
-{
- const unsigned char *x = xs, *xe = xs + m;
- const unsigned char *y = ys, *ye = ys + n;
-//2011/06/30 #define SIZEOF_VALUE 4
-#ifndef VALUE_MAX
-# if SIZEOF_VALUE == 8
-# define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL
-# elif SIZEOF_VALUE == 4
-# define VALUE_MAX 0xFFFFFFFFUL
-# elif SIZEOF_LONG == SIZEOF_VOIDP
-# define SIZEOF_VALUE 4
-# define VALUE_MAX 0xFFFFFFFFUL
-# endif
-#endif
- int hx, hy, mask = VALUE_MAX >> ((SIZEOF_VALUE - m) * CHAR_BIT);
-
- if (m > SIZEOF_VALUE)
- mrb_bug("!!too long pattern string!!");
-
- /* Prepare hash value */
- for (hx = *x++, hy = *y++; x < xe; ++x, ++y) {
- hx <<= CHAR_BIT;
- hy <<= CHAR_BIT;
- hx |= *x;
- hy |= *y;
- }
- /* Searching */
- while (hx != hy) {
- if (y == ye)
- return -1;
- hy <<= CHAR_BIT;
- hy |= *y;
- hy &= mask;
- y++;
- }
- return y - ys - m;
-}
-
-static inline long
mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
{
const unsigned char *x = xs, *xe = xs + m;
@@ -1464,6 +1334,7 @@ mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long
}
return -1;
}
+
int
mrb_memsearch(const void *x0, int m, const void *y0, int n)
{
@@ -1484,12 +1355,7 @@ mrb_memsearch(const void *x0, int m, const void *y0, int n)
}
return -1;
}
- else if (m <= SIZEOF_VALUE) {
- return mrb_memsearch_ss(x0, m, y0, n);
- }
- else {
- return mrb_memsearch_qs(x0, m, y0, n);
- }
+ return mrb_memsearch_qs(x0, m, y0, n);
}
#endif //INCLUDE_ENCODING
@@ -1507,33 +1373,6 @@ str_strlen(mrb_state *mrb, mrb_value str, mrb_encoding *enc)
p = RSTRING_PTR(str);
e = RSTRING_END(str);
cr = ENC_CODERANGE(str);
-#ifdef NONASCII_MASK
- if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
- enc == mrb_utf8_encoding(mrb)) {
-
- int len = 0;
- if ((int)sizeof(intptr_t) * 2 < e - p) {
- const intptr_t *s, *t;
- const intptr_t lowbits = sizeof(int) - 1;
- s = (const intptr_t*)(~lowbits & ((intptr_t)p + lowbits));
- t = (const intptr_t*)(~lowbits & (intptr_t)e);
- while (p < (const char *)s) {
- if (is_utf8_lead_byte(*p)) len++;
- p++;
- }
- while (s < t) {
- len += count_utf8_lead_bytes_with_word(s);
- s++;
- }
- p = (const char *)s;
- }
- while (p < e) {
- if (is_utf8_lead_byte(*p)) len++;
- p++;
- }
- return (long)len;
- }
-#endif
n = mrb_enc_strlen_cr(mrb, p, e, enc, &cr);
if (cr) {
ENC_CODERANGE_SET(str, cr);
@@ -4994,9 +4833,9 @@ mrb_str_buf_cat_escaped_char(mrb_state *mrb, mrb_value result, unsigned int c, i
char buf[CHAR_ESC_LEN + 1];
int l;
-#if SIZEOF_INT > 4
- c &= 0xffffffff;
-#endif
+ if (sizeof(c) > 4) {
+ c &= 0xffffffff;
+ }
if (unicode_p) {
if (c < 0x7F && ISPRINT(c)) {
snprintf(buf, CHAR_ESC_LEN, "%c", c);
diff --git a/src/transcode.c b/src/transcode.c
index 05d2b05b1..66a4d4e42 100644
--- a/src/transcode.c
+++ b/src/transcode.c
@@ -1770,9 +1770,9 @@ mrb_econv_putbackable(mrb_econv_t *ec)
{
if (ec->num_trans == 0)
return 0;
-#if SIZEOF_SIZE_T > SIZEOF_INT
- if (ec->elems[0].tc->readagain_len > INT_MAX) return INT_MAX;
-#endif
+ if (sizeof(size_t) > sizeof(int)) {
+ if (ec->elems[0].tc->readagain_len > INT_MAX) return INT_MAX;
+ }
return (int)ec->elems[0].tc->readagain_len;
}
@@ -2625,7 +2625,7 @@ str_transcode0(mrb_state *mrb, int argc, mrb_value *argv, mrb_value *self, int e
transcode_loop(mrb, &fromp, &bp, (sp+slen), (bp+blen), dest, str_transcoding_resize, sname, dname, ecflags, ecopts);
if (fromp != sp+slen) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "not fully converted, %td bytes left", sp+slen-fromp);
}
buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0';
diff --git a/src/variable.h b/src/variable.h
index 494099c2c..4f2f6a598 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -30,7 +30,6 @@ int mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
mrb_value mrb_obj_iv_get(mrb_state*, struct RObject*, mrb_sym);
void mrb_obj_iv_set(mrb_state*, struct RObject*, mrb_sym, mrb_value);
const char * mrb_class2name(mrb_state *mrb, struct RClass* klass);
-void mrb_define_variable(mrb_state *mrb, const char *name, mrb_value *var);
mrb_value mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym);
void mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v); /* mrb_iv_set */
void mrb_copy_generic_ivar(mrb_value clone, mrb_value obj);
diff --git a/tools/mruby/mruby.c b/tools/mruby/mruby.c
index 4e84b3c7d..769746530 100644
--- a/tools/mruby/mruby.c
+++ b/tools/mruby/mruby.c
@@ -22,10 +22,10 @@ usage(const char *name)
{
static const char *const usage_msg[] = {
"switches:",
- "-b load and execute RiteBinary(mrb) file",
+ "-b load and execute RiteBinary (mrb) file",
"-c check syntax only",
- "-v print version number, then trun on verbose mode",
- "--verbose run at verbose mode",
+ "-v print version number, then run in verbose mode",
+ "--verbose run in verbose mode",
"--version print the version",
"--copyright print the copyright",
NULL