summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-18 01:56:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-18 01:56:47 +0000
commita9662810df18371af7492dd8298cc0cccc13c7c7 (patch)
tree5a1131ad0ca461f67177e1c7282eacc92356f864
parent14aa2e8dda852b6b9277a8a7e16a78654edf1767 (diff)
1.1b8pre1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@76 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog45
-rw-r--r--array.c19
-rw-r--r--dir.c2
-rw-r--r--error.c17
-rw-r--r--eval.c74
-rw-r--r--ext/curses/curses.c1
-rw-r--r--ext/dbm/dbm.c1
-rw-r--r--ext/gtk/gtk.c542
-rw-r--r--ext/gtk/test9.rb3
-rw-r--r--ext/tcltklib/tcltklib.c1
-rw-r--r--file.c2
-rw-r--r--gc.c13
-rw-r--r--hash.c22
-rw-r--r--lib/date.rb6
-rw-r--r--lib/parsearg.rb2
-rw-r--r--lib/parsedate.rb6
-rw-r--r--marshal.c38
-rw-r--r--node.h2
-rw-r--r--object.c42
-rw-r--r--parse.y90
-rw-r--r--range.c6
-rw-r--r--re.c6
-rw-r--r--regex.c11
-rw-r--r--string.c10
-rw-r--r--struct.c16
-rw-r--r--time.c80
26 files changed, 771 insertions, 286 deletions
diff --git a/ChangeLog b/ChangeLog
index ea6cce3..813141a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,49 @@
-Mon Feb 16 14:38:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Feb 18 00:41:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
- * eval.c (f_pass_block): pass iterator block to other method.
+ * regex.c (re_match): \Z matches newline just before the end of
+ the string.
+
+Tue Feb 17 00:04:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_arg): Time.gm and Time.local now understands
+ Time#to_a format.
+
+ * string.c (str_sub_s): replace happened twice for null pattern.
+
+ * regex.c (re_search): null pattern should not match after newline
+ at the end of string.
+
+ * time.c (time_isdst): now returns boolean value.
+
+ * error.c (rb_check_type): treat special constants in messages.
+
+ * parse.y (yylex): new form `::Const' to see toplevel constants.
+
+ * parse.y (cond): SEGV on `if ()'.
+
+ * gc.c (obj_free): some data needed explicit free().
+
+Mon Feb 16 23:55:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (blk_free): release duplicated block informations.
+
+ * eval.c (blk_copy_prev): duplicate outer block information into
+ the heap, when proc/binding created.
+
+Mon Feb 16 14:38:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* time.c (time_mon): now 1 for January and so on.
- * time.c (time_year): year in 19xx (not + 1900 needed anymore).
+ * time.c (time_year): year in 19xx (no + 1900 needed anymore).
+
+Mon Feb 16 13:28:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): need to fetch mbchar's second byte
+ without translation.
+
+Mon Feb 16 12:29:27 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * eval.c (f_pass_block): pass iterator block to other method.
Fri Feb 13 08:16:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
diff --git a/array.c b/array.c
index e39f1f1..9ef50cf 100644
--- a/array.c
+++ b/array.c
@@ -115,7 +115,12 @@ ary_new4(n, elts)
VALUE ary;
ary = ary_new2(n);
- MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
+ if (elts) {
+ MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
+ }
+ else {
+ memclear(RARRAY(ary)->ptr, n);
+ }
RARRAY(ary)->len = n;
return ary;
@@ -136,14 +141,14 @@ assoc_new(car, cdr)
}
static VALUE
-ary_s_new(argc, argv, class)
+ary_s_new(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
VALUE size;
NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, class, T_ARRAY);
+ OBJSETUP(ary, klass, T_ARRAY);
rb_scan_args(argc, argv, "01", &size);
ary->len = 0;
@@ -155,13 +160,13 @@ ary_s_new(argc, argv, class)
}
static VALUE
-ary_s_create(argc, argv, class)
+ary_s_create(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, class, T_ARRAY);
+ OBJSETUP(ary, klass, T_ARRAY);
ary->len = argc;
ary->capa = argc;
diff --git a/dir.c b/dir.c
index e89f247..3d4ea58 100644
--- a/dir.c
+++ b/dir.c
@@ -199,12 +199,12 @@ static VALUE
dir_s_getwd(dir)
VALUE dir;
{
- extern char *getwd();
char path[MAXPATHLEN];
#ifdef HAVE_GETCWD
if (getcwd(path, sizeof(path)) == 0) rb_sys_fail(path);
#else
+ extern char *getwd();
if (getwd(path) == 0) rb_sys_fail(path);
#endif
diff --git a/error.c b/error.c
index 4c8aea5..1cdf469 100644
--- a/error.c
+++ b/error.c
@@ -168,8 +168,19 @@ rb_check_type(x, t)
if (TYPE(x)!=(t)) {
while (type->type >= 0) {
if (type->type == t) {
+ char *etype;
+
+ if (NIL_P(x)) {
+ etype = "nil";
+ }
+ else if (rb_special_const_p(x)) {
+ etype = RSTRING(obj_as_string(x))->ptr;
+ }
+ else {
+ etype = rb_class2name(CLASS_OF(x));
+ }
TypeError("wrong argument type %s (expected %s)",
- rb_class2name(CLASS_OF(x)), type->name);
+ etype, type->name);
}
type++;
}
@@ -342,7 +353,7 @@ Init_Exception()
rb_define_global_function("Exception", exception, -1);
}
-#define RAISE_ERROR(class) {\
+#define RAISE_ERROR(klass) {\
va_list args;\
char buf[BUFSIZ];\
\
@@ -350,7 +361,7 @@ Init_Exception()
vsprintf(buf, fmt, args);\
va_end(args);\
\
- rb_raise(exc_new2(class, buf));\
+ rb_raise(exc_new2(klass, buf));\
}
void
diff --git a/eval.c b/eval.c
index 41124c2..57aa511 100644
--- a/eval.c
+++ b/eval.c
@@ -1969,6 +1969,10 @@ rb_eval(self, node)
}
break;
+ case NODE_COLON3:
+ result = rb_const_get_at(cObject, node->nd_mid);
+ break;
+
case NODE_NTH_REF:
result = reg_nth_match(node->nd_nth, MATCH_DATA);
break;
@@ -3378,19 +3382,12 @@ f_send(argc, argv, recv)
VALUE recv;
{
VALUE vid;
- ID mid;
if (argc == 0) ArgError("no method name given");
- vid = argv[0]; argc--; argv++;
- if (TYPE(vid) == T_STRING) {
- mid = rb_intern(RSTRING(vid)->ptr);
- }
- else {
- mid = NUM2INT(vid);
- }
+ vid = *argv++; argc--;
PUSH_ITER(iterator_p()?ITER_PRE:ITER_NOT);
- vid = rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
+ vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
POP_ITER();
return vid;
@@ -3410,7 +3407,7 @@ f_pass_block(argc, argv, recv)
if (!f_iterator_p())
ArgError("pass_block called out of iterator");
- vid = argv[0]; argc--; argv++;
+ vid = *argv++; argc--;
PUSH_ITER(ITER_PRE);
vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
POP_ITER();
@@ -4349,19 +4346,45 @@ static void
blk_mark(data)
struct BLOCK *data;
{
- gc_mark_frame(&data->frame);
- gc_mark(data->scope);
- gc_mark(data->var);
- gc_mark(data->body);
- gc_mark(data->self);
- gc_mark(data->d_vars);
+ while (data) {
+ gc_mark_frame(&data->frame);
+ gc_mark(data->scope);
+ gc_mark(data->var);
+ gc_mark(data->body);
+ gc_mark(data->self);
+ gc_mark(data->d_vars);
+ data = data->prev;
+ }
}
static void
blk_free(data)
struct BLOCK *data;
{
- free(data->frame.argv);
+ struct BLOCK *tmp;
+
+ while (data) {
+ free(data->frame.argv);
+ tmp = data;
+ data = data->prev;
+ free(tmp);
+ }
+}
+
+static void
+blk_copy_prev(block)
+ struct BLOCK *block;
+{
+ struct BLOCK *tmp;
+
+ while (block->prev) {
+ tmp = ALLOC_N(struct BLOCK, 1);
+ MEMCPY(tmp, block->prev, struct BLOCK, 1);
+ tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
+ MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc);
+ block->prev = tmp;
+ block = tmp;
+ }
}
static VALUE
@@ -4375,11 +4398,21 @@ f_binding(self)
bind = Data_Make_Struct(cData, struct BLOCK, blk_mark, blk_free, data);
MEMCPY(data, the_block, struct BLOCK, 1);
+#ifdef THREAD
+ data->orig_thread = thread_current();
+#endif
data->iter = f_iterator_p();
data->frame.last_func = 0;
data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
MEMCPY(data->frame.argv, the_block->frame.argv, VALUE, data->frame.argc);
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
+
scope_dup(data->scope);
POP_BLOCK();
@@ -4412,6 +4445,12 @@ proc_s_new(klass)
data->iter = f_iterator_p();
data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
MEMCPY(data->frame.argv, the_block->frame.argv, VALUE, data->frame.argc);
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
scope_dup(data->scope);
if (safe_level >= 3) {
@@ -4794,6 +4833,7 @@ thread_free(th)
{
if (th->stk_ptr) free(th->stk_ptr);
th->stk_ptr = 0;
+ free(th);
}
static thread_t
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 3ae8db1..9984b50 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -55,6 +55,7 @@ free_window(winp)
{
if (winp->window && winp->window != stdscr) delwin(winp->window);
winp->window = 0;
+ free(winp);
}
static VALUE
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 2941877..74f8bc5 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -41,6 +41,7 @@ free_dbm(dbmp)
struct dbmdata *dbmp;
{
if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
+ free(dbmp);
}
static VALUE
diff --git a/ext/gtk/gtk.c b/ext/gtk/gtk.c
index 9c922aa..ca98982 100644
--- a/ext/gtk/gtk.c
+++ b/ext/gtk/gtk.c
@@ -103,6 +103,7 @@ static VALUE mGdk;
static VALUE gdkFont;
static VALUE gdkColor;
static VALUE gdkColormap;
+static VALUE gdkDrawable;
static VALUE gdkPixmap;
static VALUE gdkBitmap;
static VALUE gdkWindow;
@@ -121,7 +122,7 @@ static VALUE gdkEvent;
ID id_gtkdata, id_relatives, id_call, id_init;
-static void gobj_free();
+static void gobj_mark();
static GtkObject*
get_gobject(obj)
@@ -134,7 +135,7 @@ get_gobject(obj)
Check_Type(obj, T_OBJECT);
data = RDATA(rb_ivar_get(obj, id_gtkdata));
- if (NIL_P(data) || data->dfree != gobj_free) {
+ if (NIL_P(data) || data->dmark != gobj_mark) {
TypeError("not a Gtk object");
}
Data_Get_Struct(data, GtkObject, gtkp);
@@ -184,7 +185,7 @@ add_relative(obj, relative)
static VALUE gtk_object_list;
static void
-gobj_free(obj)
+gobj_mark(obj)
GtkObject *obj;
{
/* just for type mark */
@@ -210,7 +211,7 @@ set_gobject(obj, gtkobj)
{
VALUE data;
- data = Data_Wrap_Struct(cData, 0, gobj_free, gtkobj);
+ data = Data_Wrap_Struct(cData, gobj_mark, 0, gtkobj);
gtk_object_set_user_data(gtkobj, (gpointer)obj);
rb_ivar_set(obj, id_gtkdata, data);
@@ -244,8 +245,6 @@ make_widget(klass, widget)
VALUE klass;
GtkWidget *widget;
{
- VALUE obj;
-
return make_gobject(klass, GTK_OBJECT(widget));
}
@@ -320,12 +319,18 @@ get_gtkacceltbl(value)
return tbl;
}
+static void
+free_gtkprevinfo(info)
+ GtkPreviewInfo *info;
+{
+ /* no need to free() */
+}
+
static VALUE
make_gtkprevinfo(info)
GtkPreviewInfo *info;
{
- VALUE obj = Data_Wrap_Struct(gAcceleratorTable, 0, 0, info);
-
+ VALUE obj = Data_Wrap_Struct(gPreviewInfo, 0, free_gtkprevinfo, info);
rb_funcall(obj, id_init, 0, 0);
return obj;
}
@@ -347,35 +352,6 @@ get_gtkprevinfo(value)
}
static void
-signal_callback(widget, data, nparams, params)
- GtkWidget *widget;
- VALUE data;
- int nparams;
- GtkArg *params;
-{
- VALUE self = get_value_from_gobject(GTK_OBJECT(widget));
- VALUE proc = RARRAY(data)->ptr[0];
- VALUE event = RARRAY(data)->ptr[1];
- ID id = NUM2INT(event);
-
- if (NIL_P(proc) && rb_respond_to(self, id)) {
- rb_funcall(self, id, 3, self,
- INT2FIX(nparams), INT2NUM((INT)params));
- }
- else {
- rb_funcall(proc, id_call, 1, self);
- }
-}
-
-static void
-exec_callback(widget, proc)
- GtkWidget *widget;
- VALUE proc;
-{
- rb_funcall(proc, id_call, 1, get_value_from_gobject(GTK_OBJECT(widget)));
-}
-
-static void
free_ttips(tips)
GtkTooltips *tips;
{
@@ -455,13 +431,6 @@ gdkfnt_equal(fn1, fn2)
return FALSE;
}
-static void
-free_tobj(obj)
- gpointer obj;
-{
- free(obj);
-}
-
static VALUE
make_tobj(obj, klass, size)
gpointer obj;
@@ -473,7 +442,7 @@ make_tobj(obj, klass, size)
copy = xmalloc(size);
memcpy(copy, obj, size);
- data = Data_Wrap_Struct(klass, 0, free_tobj, copy);
+ data = Data_Wrap_Struct(klass, 0, (void*)-1, copy);
rb_funcall(data, id_init, 0, 0);
return data;
@@ -550,11 +519,19 @@ get_gdkcmap(cmap)
return gcmap;
}
+static void
+free_gdkvisual(visual)
+ GdkVisual *visual;
+{
+ gdk_visual_unref(visual);
+}
+
static VALUE
make_gdkvisual(visual)
GdkVisual *visual;
{
- return Data_Wrap_Struct(gdkVisual, 0, 0, visual);
+ gdk_visual_ref(visual);
+ return Data_Wrap_Struct(gdkVisual, 0, free_gdkvisual, visual);
}
static GdkVisual*
@@ -737,7 +714,6 @@ static void
free_gdkimage(image)
GdkImage *image;
{
- gdk_image_destroy(image);
}
static VALUE
@@ -763,6 +739,70 @@ get_gdkimage(image)
return gimage;
}
+static VALUE
+gdkimage_s_newbmap(klass, visual, data, w, h)
+ VALUE klass, visual, data, w, h;
+{
+ GdkImage *image;
+
+ Check_Type(data, T_STRING);
+ if (RSTRING(data)->len < w * h) {
+ ArgError("data too short");
+ }
+ return make_gdkimage(gdk_image_new_bitmap(get_gdkvisual(visual),
+ RSTRING(data)->ptr,
+ NUM2INT(w),NUM2INT(h)));
+}
+
+static VALUE
+gdkimage_s_new(klass, type, visual, w, h)
+ VALUE klass, type, visual, w, h;
+{
+ GdkImage *image;
+
+ return make_gdkimage(gdk_image_new((GdkImageType)NUM2INT(type),
+ get_gdkvisual(visual),
+ NUM2INT(w),NUM2INT(h)));
+}
+
+static VALUE
+gdkimage_s_get(klass, win, x, y, w, h)
+ VALUE klass, win, x, y, w, h;
+{
+ GdkImage *image;
+
+ return make_gdkimage(gdk_image_get(get_gdkwindow(win),
+ NUM2INT(x),NUM2INT(y),
+ NUM2INT(w),NUM2INT(h)));
+}
+
+static VALUE
+gdkimage_put_pixel(self, x, y, pix)
+ VALUE self, x, y, pix;
+{
+ gdk_image_put_pixel(get_gdkimage(self),
+ NUM2INT(x),NUM2INT(y),NUM2INT(pix));
+ return self;
+}
+
+static VALUE
+gdkimage_get_pixel(self, x, y)
+ VALUE self, x, y;
+{
+ guint32 pix;
+
+ pix = gdk_image_get_pixel(get_gdkimage(self), NUM2INT(x),NUM2INT(y));
+ return INT2NUM(pix);
+}
+
+static VALUE
+gdkimage_destroy(self)
+ VALUE self;
+{
+ gdk_image_destroy(get_gdkimage(self));
+ return Qnil;
+}
+
static void
free_gdkevent(event)
GdkEvent *event;
@@ -854,6 +894,307 @@ gslist2ary(list)
}
static VALUE
+arg_to_value(arg)
+ GtkArg *arg;
+{
+ switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
+ case GTK_TYPE_CHAR:
+ return INT2FIX(GTK_VALUE_CHAR(*arg));
+ break;
+
+ case GTK_TYPE_BOOL:
+ case GTK_TYPE_INT:
+ case GTK_TYPE_ENUM:
+ case GTK_TYPE_FLAGS:
+ return INT2NUM(GTK_VALUE_INT(*arg));
+ break;
+
+ case GTK_TYPE_UINT:
+ return INT2NUM(GTK_VALUE_UINT(*arg));
+ break;
+ case GTK_TYPE_LONG:
+ return INT2NUM(GTK_VALUE_LONG(*arg));
+ break;
+ case GTK_TYPE_ULONG:
+ return INT2NUM(GTK_VALUE_ULONG(*arg));
+ break;
+
+ case GTK_TYPE_FLOAT:
+ return float_new(GTK_VALUE_FLOAT(*arg));
+ break;
+
+ case GTK_TYPE_STRING:
+ return str_new2(GTK_VALUE_STRING(*arg));
+ break;
+
+ case GTK_TYPE_OBJECT:
+ return get_value_from_gobject(GTK_VALUE_OBJECT(*arg));
+ break;
+
+ case GTK_TYPE_SIGNAL:
+ /* signal type?? */
+ goto unsupported;
+
+ case GTK_TYPE_BOXED:
+ if (arg->type == GTK_TYPE_GDK_EVENT) {
+ return make_gdkevent(GTK_VALUE_BOXED(*arg));
+ }
+#ifdef GTK_TYPE_GDK_COLORMAP
+ else if (arg->type == GTK_TYPE_GDK_COLORMAP) {
+ return make_gdkcmap(GTK_VALUE_BOXED(*arg));
+ }
+#endif
+#ifdef GTK_TYPE_GDK_FONT
+ else if (arg->type == GTK_TYPE_GDK_FONT) {
+ return make_gdkfont(GTK_VALUE_BOXED(*arg));
+ }
+#endif
+#ifdef GTK_TYPE_GDK_PIXMAP
+ else if (arg->type == GTK_TYPE_GDK_PIXMAP) {
+ return make_gdkpixmap(gdkPixmap, GTK_VALUE_BOXED(*arg));
+ }
+#endif
+#ifdef GTK_TYPE_GDK_VISUAL
+ else if (arg->type == GTK_TYPE_GDK_VISUAL) {
+ return make_gdkvisual(GTK_VALUE_BOXED(*arg));
+ }
+#endif
+#ifdef GTK_TYPE_ACCELERATOR_TABLE
+ else if (arg->type == GTK_TYPE_ACCELERATOR_TABLE) {
+ return make_gtkacceltbl(GTK_VALUE_BOXED(*arg));
+ }
+#endif
+#ifdef GTK_TYPE_STYLE
+ else if (arg->type == GTK_TYPE_STYLE) {
+ return make_gstyle(GTK_VALUE_BOXED(*arg));
+ }
+#endif
+#ifdef GTK_TYPE_TOOLTIPS
+ else if (arg->type == GTK_TYPE_TOOLTIPS) {
+ return make_ttips(gTooltips, GTK_VALUE_BOXED(*arg));
+ }
+#endif
+ else {
+ goto unsupported;
+ }
+
+ case GTK_TYPE_POINTER:
+ return get_value_from_gobject(GTK_VALUE_OBJECT(*arg));
+ break;
+
+ case GTK_TYPE_INVALID:
+ case GTK_TYPE_NONE:
+ case GTK_TYPE_FOREIGN:
+ case GTK_TYPE_CALLBACK:
+ case GTK_TYPE_ARGS:
+ case GTK_TYPE_C_CALLBACK:
+ unsupported:
+ default:
+ TypeError("unsupported arg type %s (fundamental type %s)",
+ gtk_type_name(arg->type),
+ gtk_type_name(GTK_FUNDAMENTAL_TYPE(arg->type)));
+ break;
+ }
+}
+
+static void
+signal_setup_args(obj, sig, argc, params, args)
+ VALUE obj;
+ ID sig;
+ int argc;
+ GtkArg *params;
+ VALUE args;
+{
+ int i;
+ char *signame = rb_id2name(sig);
+
+ if (obj_is_kind_of(obj, gWidget)) {
+ if (strcmp(signame, "draw") == 0) {
+ ary_push(args, make_gdkrect(GTK_VALUE_POINTER(params[0])));
+ return;
+ }
+ if (strcmp(signame, "size_request") == 0) {
+ ary_push(args, make_grequisiton(GTK_VALUE_POINTER(params[0])));
+ return;
+ }
+ if (strcmp(signame, "size_allocate") == 0) {
+ ary_push(args, make_gallocation(GTK_VALUE_POINTER(params[0])));
+ return;
+ }
+ }
+ else if (obj_is_kind_of(obj, gWindow)) {
+ if (strcmp(signame, "move_resize") == 0) {
+ ary_push(args, NUM2INT(*GTK_RETLOC_INT(params[0])));
+ ary_push(args, NUM2INT(*GTK_RETLOC_INT(params[1])));
+ ary_push(args, NUM2INT(GTK_VALUE_INT(params[3])));
+ ary_push(args, NUM2INT(GTK_VALUE_INT(params[4])));
+ return;
+ }
+ if (strcmp(signame, "set_focus") == 0) {
+ ary_push(args, get_value_from_gobject(GTK_VALUE_POINTER(params[0])));
+ return;
+ }
+ }
+ else if (obj_is_kind_of(obj, gEntry)) {
+ if (strcmp(signame, "insert_position") == 0) {
+ ary_push(args, NUM2INT(*GTK_RETLOC_INT(params[0])));
+ return;
+ }
+ }
+ else if (obj_is_kind_of(obj, gCList)) {
+ if (strcmp(signame, "select_row") == 0) {
+ if (GTK_VALUE_POINTER(params[0]))
+ ary_push(args, make_gdkevent(GTK_VALUE_POINTER(params[0])));
+ else
+ ary_push(args, Qnil);
+ return;
+ }
+ if (strcmp(signame, "unselect_row") == 0) {
+ if (GTK_VALUE_POINTER(params[0]))
+ ary_push(args, make_gdkevent(GTK_VALUE_POINTER(params[0])));
+ else
+ ary_push(args, Qnil);
+ return;
+ }
+ }
+
+ for (i=0; i<argc; i++) {
+ ary_push(args, arg_to_value(params));
+ params++;
+ }
+}
+
+static void
+arg_set_value(arg, value)
+ GtkArg *arg;
+ VALUE value;
+{
+ char *type = 0;
+
+ switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
+ case GTK_TYPE_NONE:
+ break;
+
+ case GTK_TYPE_CHAR:
+ *GTK_RETLOC_CHAR(*arg) = NUM2INT(value);
+ break;
+ case GTK_TYPE_BOOL:
+ case GTK_TYPE_INT:
+ case GTK_TYPE_ENUM:
+ case GTK_TYPE_FLAGS:
+ *GTK_RETLOC_INT(*arg) = NUM2INT(value);
+ break;
+ case GTK_TYPE_UINT:
+ *GTK_RETLOC_UINT(*arg) = NUM2INT(value);
+ break;
+ case GTK_TYPE_LONG:
+ *GTK_RETLOC_LONG(*arg) = NUM2INT(value);
+ break;
+ case GTK_TYPE_ULONG:
+ *GTK_RETLOC_ULONG(*arg) = NUM2INT(value);
+ break;
+
+ case GTK_TYPE_FLOAT:
+ value = rb_Float(value);
+ *GTK_RETLOC_FLOAT(*arg) = (float)RFLOAT(value)->value;
+ break;
+
+ case GTK_TYPE_STRING:
+ *GTK_RETLOC_STRING(*arg) = STR2CSTR(value);
+ break;
+
+ case GTK_TYPE_OBJECT:
+ *GTK_RETLOC_OBJECT(*arg) = get_gobject(value);
+ break;
+
+ case GTK_TYPE_POINTER:
+ *GTK_RETLOC_POINTER(*arg) = (gpointer)value;
+ break;
+
+ case GTK_TYPE_BOXED:
+ if (arg->type == GTK_TYPE_GDK_EVENT)
+ GTK_VALUE_BOXED(*arg) = get_gdkevent(value);
+#ifdef GTK_TYPE_GDK_COLORMAP
+ else if (arg->type == GTK_TYPE_GDK_COLORMAP)
+ GTK_VALUE_BOXED(*arg) = get_gdkcmap(value);
+#endif
+#ifdef GTK_TYPE_GDK_FONT
+ else if (arg->type == GTK_TYPE_GDK_FONT)
+ GTK_VALUE_BOXED(*arg) = get_gdkfont(value);
+#endif
+#ifdef GTK_TYPE_GDK_PIXMAP
+ else if (arg->type == GTK_TYPE_GDK_PIXMAP)
+ GTK_VALUE_BOXED(*arg) = get_gdkpixmap(value);
+#endif
+#ifdef GTK_TYPE_GDK_VISUAL
+ else if (arg->type == GTK_TYPE_GDK_VISUAL)
+ GTK_VALUE_BOXED(*arg) = get_gdkvisual(value);
+#endif
+#ifdef GTK_TYPE_ACCELERATOR_TABLE
+ else if (arg->type == GTK_TYPE_ACCELERATOR_TABLE)
+ GTK_VALUE_BOXED(*arg) = get_gtkacceltbl(value);
+#endif
+#ifdef GTK_TYPE_STYLE
+ else if (arg->type == GTK_TYPE_STYLE)
+ GTK_VALUE_BOXED(*arg) = get_gstyle(value);
+#endif
+#ifdef GTK_TYPE_TOOLTIPS
+ else if (arg->type == GTK_TYPE_TOOLTIPS)
+ GTK_VALUE_BOXED(*arg) = get_ttips(value);
+#endif
+ else
+ goto unsupported;
+
+ unsupported:
+ case GTK_TYPE_INVALID:
+ case GTK_TYPE_FOREIGN:
+ case GTK_TYPE_CALLBACK:
+ case GTK_TYPE_ARGS:
+ case GTK_TYPE_SIGNAL:
+ case GTK_TYPE_C_CALLBACK:
+ default:
+ TypeError("unsupported return type %s (fundamental type %s)",
+ gtk_type_name(arg->type),
+ gtk_type_name(GTK_FUNDAMENTAL_TYPE(arg->type)));
+ break;
+ }
+}
+
+static void
+signal_callback(widget, data, nparams, params)
+ GtkWidget *widget;
+ VALUE data;
+ int nparams;
+ GtkArg *params;
+{
+ VALUE self = get_value_from_gobject(GTK_OBJECT(widget));
+ VALUE proc = RARRAY(data)->ptr[0];
+ ID id = NUM2INT(RARRAY(data)->ptr[1]);
+ VALUE result = Qnil;
+ VALUE args = ary_new2(nparams+1);
+
+ signal_setup_args(self, id, nparams, params, args);
+ if (NIL_P(proc)) {
+ if (rb_respond_to(self, id)) {
+ result = rb_apply(self, id, args);
+ }
+ }
+ else {
+ ary_unshift(args, self);
+ result = rb_apply(proc, id_call, args);
+ }
+ arg_set_value(params+nparams, result);
+}
+
+static void
+exec_callback(widget, proc)
+ GtkWidget *widget;
+ VALUE proc;
+{
+ rb_funcall(proc, id_call, 1, get_value_from_gobject(GTK_OBJECT(widget)));
+}
+
+static VALUE
gobj_initialize(argc, argv, self)
int argc;
VALUE *argv;
@@ -870,11 +1211,11 @@ gobj_smethod_added(self, id)
char *name = rb_id2name(NUM2INT(id));
if (gtk_signal_lookup(name, GTK_OBJECT_TYPE(obj))) {
- VALUE handler = assoc_new(Qnil, id);
+ VALUE data = assoc_new(Qnil, id);
- add_relative(self, handler);
+ add_relative(self, data);
gtk_signal_connect_interp(obj, name,
- signal_callback, (gpointer)handler,
+ signal_callback, (gpointer)data,
NULL, 0);
}
return Qnil;
@@ -884,9 +1225,7 @@ static VALUE
gobj_destroy(self)
VALUE self;
{
- printf("a\n");
gtk_object_destroy(get_gobject(self));
- printf("b\n");
clear_gobject(self);
return Qnil;
}
@@ -915,21 +1254,21 @@ gobj_sig_connect(argc, argv, self)
VALUE *argv;
VALUE self;
{
- VALUE sig, handler;
+ VALUE sig, data;
GtkWidget *widget = get_widget(self);
ID id = 0;
int n;
- rb_scan_args(argc, argv, "11", &sig, &handler);
+ rb_scan_args(argc, argv, "11", &sig, &data);
Check_Type(sig, T_STRING);
- if (NIL_P(handler) && iterator_p()) {
- handler = f_lambda();
+ if (NIL_P(data) && iterator_p()) {
+ data = f_lambda();
id = rb_intern(RSTRING(sig)->ptr);
}
- handler = assoc_new(handler, INT2NUM(id));
- add_relative(self, handler);
+ data = assoc_new(data, INT2NUM(id));
+ add_relative(self, data);
n = gtk_signal_connect_interp(GTK_OBJECT(widget), RSTRING(sig)->ptr,
- signal_callback, (gpointer)handler,
+ signal_callback, (gpointer)data,
NULL, 0);
return INT2FIX(n);
@@ -941,20 +1280,20 @@ gobj_sig_connect_after(argc, argv, self)
VALUE *argv;
VALUE self;
{
- VALUE sig, handler;
+ VALUE sig, data;
GtkWidget *widget = get_widget(self);
ID id = 0;
int n;
- rb_scan_args(argc, argv, "11", &sig, &handler);
+ rb_scan_args(argc, argv, "11", &sig, &data);
Check_Type(sig, T_STRING);
- if (NIL_P(handler) && iterator_p()) {
- handler = f_lambda();
+ if (NIL_P(data) && iterator_p()) {
+ data = f_lambda();
id = rb_intern(RSTRING(sig)->ptr);
}
- add_relative(self, handler);
+ add_relative(self, data);
n = gtk_signal_connect_interp(GTK_OBJECT(widget), RSTRING(sig)->ptr,
- signal_callback, (gpointer)handler,
+ signal_callback, (gpointer)data,
NULL, 1);
return INT2FIX(n);
@@ -1437,14 +1776,6 @@ widget_grab_default(self)
}
static VALUE
-widget_restore_state(self)
- VALUE self;
-{
- gtk_widget_restore_state(get_widget(self));
- return self;
-}
-
-static VALUE
widget_visible(self)
VALUE self;
{
@@ -4033,7 +4364,7 @@ vport_set_vadj(self, adj)
GtkObject *adjustment = get_gobject(adj);
gtk_viewport_set_vadjustment(GTK_VIEWPORT(widget),
- GTK_ADJUSTMENT(adj));
+ GTK_ADJUSTMENT(adjustment));
return self;
}
@@ -4046,7 +4377,7 @@ vport_set_hadj(self, adj)
GtkObject *adjustment = get_gobject(adj);
gtk_viewport_set_hadjustment(GTK_VIEWPORT(widget),
- GTK_ADJUSTMENT(adj));
+ GTK_ADJUSTMENT(adjustment));
return self;
}
@@ -5159,6 +5490,7 @@ set_warning_handler(argc, argv, self)
handler = f_lambda();
}
g_set_warning_handler(gtkwarn);
+ return handler;
}
static VALUE
@@ -5174,6 +5506,7 @@ set_message_handler(argc, argv, self)
handler = f_lambda();
}
g_set_message_handler(gtkmesg);
+ return handler;
}
static VALUE
@@ -5189,6 +5522,7 @@ set_print_handler(argc, argv, self)
handler = f_lambda();
}
g_set_print_handler(gtkprint);
+ return handler;
}
static void
@@ -5293,9 +5627,10 @@ Init_gtk()
gdkFont = rb_define_class_under(mGdk, "Font", cObject);
gdkColor = rb_define_class_under(mGdk, "Color", cObject);
- gdkPixmap = rb_define_class_under(mGdk, "Pixmap", cObject);
+ gdkDrawable = rb_define_class_under(mGdk, "Drawable", cObject);
+ gdkPixmap = rb_define_class_under(mGdk, "Pixmap", gdkDrawable);
gdkBitmap = rb_define_class_under(mGdk, "Bitmap", gdkPixmap);
- gdkWindow = rb_define_class_under(mGdk, "Window", cObject);
+ gdkWindow = rb_define_class_under(mGdk, "Window", gdkDrawable);
gdkImage = rb_define_class_under(mGdk, "Image", cObject);
gdkVisual = rb_define_class_under(mGdk, "Visual", cObject);
gdkGC = rb_define_class_under(mGdk, "GC", cObject);
@@ -5341,13 +5676,13 @@ Init_gtk()
rb_define_method(gWidget, "activate", widget_activate, 0);
rb_define_method(gWidget, "grab_focus", widget_grab_focus, 0);
rb_define_method(gWidget, "grab_default", widget_grab_default, 0);
- rb_define_method(gWidget, "restore_state", widget_restore_state, 0);
+ rb_define_method(gWidget, "set_state", widget_set_state, 1);
rb_define_method(gWidget, "visible?", widget_visible, 0);
rb_define_method(gWidget, "reparent", widget_reparent, 1);
rb_define_method(gWidget, "popup", widget_popup, 2);
rb_define_method(gWidget, "intersect", widget_intersect, 2);
rb_define_method(gWidget, "basic", widget_basic, 0);
- rb_define_method(gWidget, "get_name", widget_set_name, 0);
+ rb_define_method(gWidget, "get_name", widget_get_name, 0);
rb_define_method(gWidget, "set_name", widget_set_name, 1);
rb_define_method(gWidget, "set_parent", widget_set_parent, 1);
rb_define_method(gWidget, "set_sensitive", widget_set_sensitive, 1);
@@ -5365,7 +5700,7 @@ Init_gtk()
rb_define_method(gWidget, "style", widget_get_style, 0);
rb_define_method(gWidget, "get_events", widget_get_events, 0);
rb_define_method(gWidget, "get_extension_events", widget_get_eevents, 0);
- rb_define_method(gWidget, "get_pointer", widget_get_eevents, 0);
+ rb_define_method(gWidget, "get_pointer", widget_get_pointer, 0);
rb_define_method(gWidget, "ancestor?", widget_is_ancestor, 1);
rb_define_method(gWidget, "child?", widget_is_child, 1);
rb_define_method(gWidget, "window", widget_window, 0);
@@ -5428,7 +5763,7 @@ Init_gtk()
/* Arrow */
rb_define_method(gArrow, "initialize", arrow_initialize, 2);
- rb_define_method(gArrow, "set", arrow_initialize, 2);
+ rb_define_method(gArrow, "set", arrow_set, 2);
/* Frame */
rb_define_method(gFrame, "initialize", frame_initialize, 1);
@@ -5500,8 +5835,8 @@ Init_gtk()
rb_define_method(gCList, "column_titles_hide", clist_col_titles_hide, 0);
rb_define_method(gCList, "column_title_active", clist_col_title_active, 1);
rb_define_method(gCList, "column_title_passive", clist_col_title_passive, 1);
- rb_define_method(gCList, "column_titles_active", clist_col_title_active, 0);
- rb_define_method(gCList, "column_titles_passive", clist_col_title_passive, 0);
+ rb_define_method(gCList, "column_titles_active", clist_col_titles_active, 0);
+ rb_define_method(gCList, "column_titles_passive", clist_col_titles_passive, 0);
rb_define_method(gCList, "set_column_title", clist_set_col_title, 2);
rb_define_method(gCList, "set_column_widget", clist_set_col_wigdet, 2);
rb_define_method(gCList, "set_column_justification", clist_set_col_just, 2);
@@ -5509,7 +5844,7 @@ Init_gtk()
rb_define_method(gCList, "set_row_height", clist_set_row_height, 1);
rb_define_method(gCList, "moveto", clist_moveto, 4);
rb_define_method(gCList, "set_text", clist_set_text, 3);
- rb_define_method(gCList, "set_pixmap", clist_set_text, 4);
+ rb_define_method(gCList, "set_pixmap", clist_set_pixmap, 4);
rb_define_method(gCList, "set_pixtext", clist_set_pixtext, 6);
rb_define_method(gCList, "set_foreground", clist_set_foreground, 2);
rb_define_method(gCList, "set_background", clist_set_background, 2);
@@ -5518,7 +5853,7 @@ Init_gtk()
rb_define_method(gCList, "insert", clist_insert, 2);
rb_define_method(gCList, "remove", clist_remove, 1);
rb_define_method(gCList, "set_row_data", clist_set_row_data, 2);
- rb_define_method(gCList, "get_row_data", clist_set_row_data, 1);
+ rb_define_method(gCList, "get_row_data", clist_get_row_data, 1);
rb_define_method(gCList, "select_row", clist_select_row, 2);
rb_define_method(gCList, "unselect_row", clist_unselect_row, 2);
rb_define_method(gCList, "clear", clist_clear, 0);
@@ -5529,7 +5864,7 @@ Init_gtk()
rb_define_method(gWindow, "set_policy", gwin_set_policy, 3);
rb_define_method(gWindow, "set_wmclass", gwin_set_wmclass, 1);
rb_define_method(gWindow, "set_focus", gwin_set_focus, 1);
- rb_define_method(gWindow, "set_default", gwin_set_focus, 1);
+ rb_define_method(gWindow, "set_default", gwin_set_default, 1);
rb_define_method(gWindow, "add_accelerator_table", gwin_add_accel, 1);
rb_define_method(gWindow, "remove_accelerator_table", gwin_rm_accel, 1);
rb_define_method(gWindow, "position", gwin_position, 1);
@@ -5588,7 +5923,7 @@ Init_gtk()
rb_define_singleton_method(gHBBox, "get_spacing_default",
hbbox_get_spacing_default, 0);
rb_define_singleton_method(gHBBox, "get_layout_default",
- hbbox_get_spacing_default, 0);
+ hbbox_get_layout_default, 0);
rb_define_singleton_method(gHBBox, "set_spacing_default",
hbbox_set_spacing_default, 1);
rb_define_singleton_method(gHBBox, "set_layout_default",
@@ -5599,7 +5934,7 @@ Init_gtk()
rb_define_singleton_method(gVBBox, "get_spacing_default",
vbbox_get_spacing_default, 0);
rb_define_singleton_method(gVBBox, "get_layout_default",
- vbbox_get_spacing_default, 0);
+ vbbox_get_layout_default, 0);
rb_define_singleton_method(gVBBox, "set_spacing_default",
vbbox_set_spacing_default, 1);
rb_define_singleton_method(gVBBox, "set_layout_default",
@@ -5610,7 +5945,7 @@ Init_gtk()
/* Paned */
rb_define_method(gPaned, "add1", paned_add1, 1);
- rb_define_method(gPaned, "add2", paned_add1, 1);
+ rb_define_method(gPaned, "add2", paned_add2, 1);
rb_define_method(gPaned, "handle_size", paned_handle_size, 1);
rb_define_method(gPaned, "gutter_size", paned_gutter_size, 1);
@@ -5725,7 +6060,7 @@ Init_gtk()
rb_define_method(gMenu, "prepend", menu_prepend, 1);
rb_define_method(gMenu, "insert", menu_insert, 2);
rb_define_method(gMenu, "popup", menu_popup, 6);
- rb_define_method(gMenu, "popdown", menu_popup, 0);
+ rb_define_method(gMenu, "popdown", menu_popdown, 0);
rb_define_method(gMenu, "get_active", menu_get_active, 0);
rb_define_method(gMenu, "set_active", menu_set_active, 1);
rb_define_method(gMenu, "set_accelerator_table", menu_set_acceltbl, 1);
@@ -5780,7 +6115,7 @@ Init_gtk()
rb_define_method(gOptionMenu, "initialize", omenu_initialize, 0);
rb_define_method(gOptionMenu, "get_menu", omenu_get_menu, 0);
rb_define_method(gOptionMenu, "set_menu", omenu_set_menu, 1);
- rb_define_method(gOptionMenu, "remove_menu", omenu_set_menu, 0);
+ rb_define_method(gOptionMenu, "remove_menu", omenu_remove_menu, 0);
rb_define_method(gOptionMenu, "set_history", omenu_set_history, 1);
/* Pixmap */
@@ -5839,10 +6174,10 @@ Init_gtk()
rb_define_method(gToolbar, "initialize", tbar_initialize, -1);
rb_define_method(gToolbar, "append_item", tbar_append_item, 4);
rb_define_method(gToolbar, "prepend_item", tbar_prepend_item, 4);
- rb_define_method(gToolbar, "insert_item", tbar_append_item, 5);
+ rb_define_method(gToolbar, "insert_item", tbar_insert_item, 5);
rb_define_method(gToolbar, "append_space", tbar_append_space, 0);
rb_define_method(gToolbar, "prepend_space", tbar_prepend_space, 0);
- rb_define_method(gToolbar, "insert_space", tbar_append_space, 1);
+ rb_define_method(gToolbar, "insert_space", tbar_insert_space, 1);
rb_define_method(gToolbar, "set_orientation", tbar_set_orientation, 1);
rb_define_method(gToolbar, "set_style", tbar_set_style, 1);
rb_define_method(gToolbar, "set_space_size", tbar_set_space_size, 1);
@@ -5899,21 +6234,30 @@ Init_gtk()
rb_define_method(gdkFont, "==", gdkfnt_equal, 1);
/* GdkBitmap */
- rb_define_method(gdkBitmap, "new", gdkbmap_s_new, 3);
+ rb_define_singleton_method(gdkBitmap, "new", gdkbmap_s_new, 3);
rb_define_singleton_method(gdkBitmap, "create_from_data",
gdkbmap_create_from_data, 4);
/* GdkPixmap */
- rb_define_method(gdkPixmap, "new", gdkpmap_s_new, 4);
+ rb_define_singleton_method(gdkPixmap, "new", gdkpmap_s_new, 4);
+ rb_define_singleton_method(gdkPixmap, "create_from_data",
+ gdkpmap_create_from_data, 7);
rb_define_singleton_method(gdkPixmap, "create_from_xpm",
gdkpmap_create_from_xpm, 3);
rb_define_singleton_method(gdkPixmap, "create_from_xpm_d",
- gdkpmap_create_from_xpm, 3);
+ gdkpmap_create_from_xpm_d, 3);
/* GdkWindow */
/* GdkImage */
-
+ rb_define_singleton_method(gdkImage, "new_bitmap", gdkimage_s_newbmap, 4);
+ rb_define_singleton_method(gdkImage, "new", gdkimage_s_new, 4);
+ rb_define_singleton_method(gdkImage, "get", gdkimage_s_get, 5);
+ rb_define_method(gdkImage, "put_pixel", gdkimage_put_pixel, 3);
+ rb_define_method(gdkImage, "get_pixel", gdkimage_get_pixel, 2);
+ rb_define_method(gdkImage, "destroy", gdkimage_destroy, 0);
+
+ /* constants */
rb_define_const(mGtk, "VISIBLE", INT2FIX(GTK_VISIBLE));
rb_define_const(mGtk, "MAPPED", INT2FIX(GTK_MAPPED));
rb_define_const(mGtk, "UNMAPPED", INT2FIX(GTK_UNMAPPED));
@@ -6021,6 +6365,10 @@ Init_gtk()
rb_define_const(mGdk, "EXTENSION_EVENTS_ALL", INT2FIX(GDK_EXTENSION_EVENTS_ALL));
rb_define_const(mGdk, "EXTENSION_EVENTS_CURSOR", INT2FIX(GDK_EXTENSION_EVENTS_CURSOR));
+ rb_define_const(mGdk, "IMAGE_NORMAL", INT2FIX(GDK_IMAGE_NORMAL));
+ rb_define_const(mGdk, "IMAGE_SHARED", INT2FIX(GDK_IMAGE_SHARED));
+ rb_define_const(mGdk, "IMAGE_FASTEST", INT2FIX(GDK_IMAGE_FASTEST));
+
argc = RARRAY(rb_argv)->len;
argv = ALLOCA_N(char*,argc+1);
argv[0] = RSTRING(rb_argv0)->ptr;
diff --git a/ext/gtk/test9.rb b/ext/gtk/test9.rb
index 7bb3bf3..0149718 100644
--- a/ext/gtk/test9.rb
+++ b/ext/gtk/test9.rb
@@ -3,9 +3,6 @@ require 'gtk'
def create_bbox_window(horizontal, title, pos, spacing, cw, ch, layout)
window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
window.set_title(title)
- window.signal_connect("destroy") do
- window.destroy
- end
window.signal_connect("delete_event") do
window.hide
window.destroy
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index e7fe77d..6bebb88 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -115,6 +115,7 @@ ip_free(struct tcltkip *ptr)
{
DUMP1("Tcl_DeleteInterp");
Tcl_DeleteInterp(ptr->ip);
+ free(ptr);
}
/* create and initialize interpreter */
diff --git a/file.c b/file.c
index b189a23..34f0d44 100644
--- a/file.c
+++ b/file.c
@@ -1187,7 +1187,7 @@ file_s_expand_path(obj, fname)
VALUE obj, fname;
{
char *s, *p;
- char buf[MAXPATHLEN];
+ char buf[MAXPATHLEN+2];
Check_Type(fname, T_STRING);
s = RSTRING(fname)->ptr;
diff --git a/gc.c b/gc.c
index 9eab3b6..36cb6d1 100644
--- a/gc.c
+++ b/gc.c
@@ -663,8 +663,17 @@ obj_free(obj)
free(RANY(obj)->as.regexp.str);
break;
case T_DATA:
- if (RANY(obj)->as.data.dfree && DATA_PTR(obj))
- (*RANY(obj)->as.data.dfree)(DATA_PTR(obj));
+ if (DATA_PTR(obj)) {
+ if (RANY(obj)->as.data.dfree == (void*)-1) {
+ free(DATA_PTR(obj));
+ }
+ if (RANY(obj)->as.data.dfree) {
+ (*RANY(obj)->as.data.dfree)(DATA_PTR(obj));
+ }
+ else {
+ free(DATA_PTR(obj));
+ }
+ }
break;
case T_MATCH:
re_free_registers(RANY(obj)->as.match.regs);
diff --git a/hash.c b/hash.c
index b36cfa2..3f1640c 100644
--- a/hash.c
+++ b/hash.c
@@ -184,16 +184,16 @@ hash_foreach(hash, func, farg)
}
static VALUE
-hash_s_new(argc, argv, class)
+hash_s_new(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
VALUE sz;
int size;
NEWOBJ(hash, struct RHash);
- OBJSETUP(hash, class, T_HASH);
+ OBJSETUP(hash, klass, T_HASH);
rb_scan_args(argc, argv, "01", &sz);
if (NIL_P(sz)) size = 0;
@@ -208,10 +208,10 @@ hash_s_new(argc, argv, class)
}
static VALUE
-hash_new2(class)
- VALUE class;
+hash_new2(klass)
+ VALUE klass;
{
- return hash_s_new(0, 0, class);
+ return hash_s_new(0, 0, klass);
}
VALUE
@@ -221,19 +221,19 @@ hash_new()
}
static VALUE
-hash_s_create(argc, argv, class)
+hash_s_create(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
VALUE hash;
int i;
if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- if (class == CLASS_OF(argv[0])) return argv[0];
+ if (klass == CLASS_OF(argv[0])) return argv[0];
else {
NEWOBJ(hash, struct RHash);
- OBJSETUP(hash, class, T_HASH);
+ OBJSETUP(hash, klass, T_HASH);
hash->iter_lev = 0;
hash->status = 0;
@@ -246,7 +246,7 @@ hash_s_create(argc, argv, class)
if (argc % 2 != 0) {
ArgError("odd number args for Hash");
}
- hash = hash_new2(class);
+ hash = hash_new2(klass);
for (i=0; i<argc; i+=2) {
st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
diff --git a/lib/date.rb b/lib/date.rb
index 2d5090b..030b8a3 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1,8 +1,8 @@
#
# Date.rb -
# $Release Version: $
-# $Revision: 1.1.1.1.4.2 $
-# $Date: 1998/02/02 04:49:13 $
+# $Revision: 1.1.1.1.4.3 $
+# $Date: 1998/02/03 10:02:57 $
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
@@ -183,7 +183,7 @@ end
def Date.at(d)
if d.kind_of? Time
- return Date.new(1900+d.year, d.mon+1, d.mday)
+ return Date.new(d.year, d.mon, d.mday)
end
if d.kind_of? Date
return Date.at(d.period)
diff --git a/lib/parsearg.rb b/lib/parsearg.rb
index 6811dd3..fa4dbde 100644
--- a/lib/parsearg.rb
+++ b/lib/parsearg.rb
@@ -13,7 +13,7 @@
$RCS_ID=%q$Header$
-load("getopts.rb")
+require "getopts"
def printUsageAndExit()
if $USAGE
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 861e036..4ae8fc1 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -10,8 +10,10 @@ module ParseDate
DAYPAT = DAYS.keys.join('|')
def parsedate(date)
- # ISO 8601?
- if date =~ /^(\d\d\d\d)-?(?:(\d\d)-?(\d\d)?)? *(?:(\d\d):(\d\d)(?::(\d\d))?)?$/
+ # part of ISO 8601
+ # yyyy-mm-dd | yyyy-mm | yyyy
+ # date hh:mm:ss | date Thh:mm:ss
+ if date =~ /^(\d\d\d\d)-?(?:(\d\d)-?(\d\d)?)? *T?(?:(\d\d):?(\d\d):?(\d\d)?)?$/
return $1.to_i,
if $2 then $2.to_i else 1 end,
if $3 then $3.to_i else 1 end,
diff --git a/marshal.c b/marshal.c
index 7d4d987..b9c583e 100644
--- a/marshal.c
+++ b/marshal.c
@@ -192,11 +192,11 @@ obj_each(id, value, arg)
}
static void
-w_uclass(obj, class, arg)
- VALUE obj, class;
+w_uclass(obj, klass, arg)
+ VALUE obj, klass;
struct dump_arg *arg;
{
- if (CLASS_OF(obj) != class) {
+ if (CLASS_OF(obj) != klass) {
w_byte(TYPE_UCLASS, arg);
w_unique(rb_class2name(CLASS_OF(obj)), arg);
}
@@ -356,13 +356,13 @@ w_object(obj, arg, limit)
case T_OBJECT:
w_byte(TYPE_OBJECT, arg);
{
- VALUE class = CLASS_OF(obj);
+ VALUE klass = CLASS_OF(obj);
char *path;
- if (FL_TEST(class, FL_SINGLETON)) {
+ if (FL_TEST(klass, FL_SINGLETON)) {
TypeError("singleton can't be dumped");
}
- path = rb_class2name(class);
+ path = rb_class2name(klass);
w_unique(path, arg);
if (ROBJECT(obj)->iv_tbl) {
w_long(ROBJECT(obj)->iv_tbl->num_entries, arg);
@@ -710,13 +710,13 @@ r_object(arg)
case TYPE_STRUCT:
{
- VALUE class, mem, values;
+ VALUE klass, mem, values;
volatile int i; /* gcc 2.7.2.3 -O2 bug?? */
int len;
ID slot;
- class = rb_path2class(r_unique(arg));
- mem = rb_ivar_get(class, rb_intern("__member__"));
+ klass = rb_path2class(r_unique(arg));
+ mem = rb_ivar_get(klass, rb_intern("__member__"));
if (mem == Qnil) {
Fatal("non-initialized struct");
}
@@ -726,14 +726,14 @@ r_object(arg)
for (i=0; i<len; i++) {
ary_push(values, Qnil);
}
- v = struct_alloc(class, values);
+ v = struct_alloc(klass, values);
r_regist(v, arg);
for (i=0; i<len; i++) {
slot = r_symbol(arg);
if (RARRAY(mem)->ptr[i] != INT2FIX(slot)) {
TypeError("struct %s not compatible (:%s for :%s)",
- rb_class2name(class),
+ rb_class2name(klass),
rb_id2name(slot),
rb_id2name(FIX2INT(RARRAY(mem)->ptr[i])));
}
@@ -745,27 +745,27 @@ r_object(arg)
case TYPE_USERDEF:
{
- VALUE class;
+ VALUE klass;
int len;
- class = rb_path2class(r_unique(arg));
- if (rb_respond_to(class, s_load)) {
- v = rb_funcall(class, s_load, 1, r_string(arg));
+ klass = rb_path2class(r_unique(arg));
+ if (rb_respond_to(klass, s_load)) {
+ v = rb_funcall(klass, s_load, 1, r_string(arg));
return r_regist(v, arg);
}
TypeError("class %s needs to have method `_load_from'",
- rb_class2name(class));
+ rb_class2name(klass));
}
break;
case TYPE_OBJECT:
{
- VALUE class;
+ VALUE klass;
int len;
- class = rb_path2class(r_unique(arg));
+ klass = rb_path2class(r_unique(arg));
len = r_long(arg);
- v = obj_alloc(class);
+ v = obj_alloc(klass);
r_regist(v, arg);
if (len > 0) {
while (len--) {
diff --git a/node.h b/node.h
index b5a837a..eb94ceb 100644
--- a/node.h
+++ b/node.h
@@ -86,6 +86,7 @@ enum node_type {
NODE_MODULE,
NODE_SCLASS,
NODE_COLON2,
+ NODE_COLON3,
NODE_CNAME,
NODE_CREF,
NODE_DOT2,
@@ -281,6 +282,7 @@ typedef struct RNode {
#define NEW_SCLASS(r,b) node_newnode(NODE_SCLASS,r,NEW_CBODY(b),0)
#define NEW_MODULE(n,b) node_newnode(NODE_MODULE,n,NEW_CBODY(b),0)
#define NEW_COLON2(c,i) node_newnode(NODE_COLON2,c,i,0)
+#define NEW_COLON3(i) node_newnode(NODE_COLON3,0,i,0)
#define NEW_CREF0() (cur_cref=node_newnode(NODE_CREF,RNODE(the_frame->cbase)->nd_clss,0,0))
#define NEW_CREF() (cur_cref=node_newnode(NODE_CREF,0,0,cur_cref))
#define NEW_CBODY(b) (cur_cref->nd_body=NEW_SCOPE(b),cur_cref)
diff --git a/object.c b/object.c
index 90d774a..3339364 100644
--- a/object.c
+++ b/object.c
@@ -357,11 +357,11 @@ rb_false(obj)
}
VALUE
-obj_alloc(class)
- VALUE class;
+obj_alloc(klass)
+ VALUE klass;
{
NEWOBJ(obj, struct RObject);
- OBJSETUP(obj, class, T_OBJECT);
+ OBJSETUP(obj, klass, T_OBJECT);
obj->iv_tbl = 0;
return (VALUE)obj;
@@ -383,10 +383,10 @@ mod_clone(module)
}
static VALUE
-mod_to_s(class)
- VALUE class;
+mod_to_s(klass)
+ VALUE klass;
{
- return str_dup(rb_class_path(class));
+ return str_dup(rb_class_path(klass));
}
static VALUE
@@ -501,10 +501,10 @@ VALUE class_instance_methods();
VALUE class_private_instance_methods();
static VALUE
-class_superclass(cl)
- VALUE cl;
+class_superclass(klass)
+ VALUE klass;
{
- VALUE super = RCLASS(cl)->super;
+ VALUE super = RCLASS(klass)->super;
while (TYPE(super) == T_ICLASS) {
super = RCLASS(super)->super;
@@ -527,56 +527,56 @@ rb_to_id(name)
}
static VALUE
-mod_attr(argc, argv, class)
+mod_attr(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
VALUE name, pub;
rb_scan_args(argc, argv, "11", &name, &pub);
- rb_define_attr(class, rb_to_id(name), 1, RTEST(pub));
+ rb_define_attr(klass, rb_to_id(name), 1, RTEST(pub));
return Qnil;
}
static VALUE
-mod_attr_reader(argc, argv, class)
+mod_attr_reader(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
int i;
for (i=0; i<argc; i++) {
- rb_define_attr(class, rb_to_id(argv[i]), 1, 0);
+ rb_define_attr(klass, rb_to_id(argv[i]), 1, 0);
}
return Qnil;
}
static VALUE
-mod_attr_writer(argc, argv, class)
+mod_attr_writer(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
int i;
for (i=0; i<argc; i++) {
- rb_define_attr(class, rb_to_id(argv[i]), 0, 1);
+ rb_define_attr(klass, rb_to_id(argv[i]), 0, 1);
}
return Qnil;
}
static VALUE
-mod_attr_accessor(argc, argv, class)
+mod_attr_accessor(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
int i;
for (i=0; i<argc; i++) {
- rb_define_attr(class, rb_to_id(argv[i]), 1, 1);
+ rb_define_attr(klass, rb_to_id(argv[i]), 1, 1);
}
return Qnil;
}
diff --git a/parse.y b/parse.y
index 4331857..761b2c8 100644
--- a/parse.y
+++ b/parse.y
@@ -192,6 +192,7 @@ static void top_local_setup();
%token AREF ASET /* [] and []= */
%token LSHFT RSHFT /* << and >> */
%token COLON2 /* :: */
+%token COLON3 /* :: at EXPR_BEG */
%token <id> OP_ASGN /* +=, -= etc. */
%token ASSOC /* => */
%token KW_ASSOC /* -> */
@@ -808,8 +809,13 @@ primary : literal
}
| primary COLON2 cname
{
+ value_expr($1);
$$ = NEW_COLON2($1, $3);
}
+ | COLON3 cname
+ {
+ $$ = NEW_COLON3($2);
+ }
| STRING
{
$$ = NEW_STR($1);
@@ -1261,7 +1267,7 @@ superclass : term
{
$$ = $3;
}
- | error term {yyerrok; $$ = 0}
+ | error term {yyerrok; $$ = 0;}
f_arglist : '(' f_args ')'
{
@@ -2567,6 +2573,11 @@ retry:
case ':':
c = nextc();
if (c == ':') {
+ if (lex_state == EXPR_BEG ||
+ (lex_state == EXPR_ARG && space_seen)) {
+ lex_state = EXPR_BEG;
+ return COLON3;
+ }
lex_state = EXPR_BEG;
return COLON2;
}
@@ -3422,43 +3433,6 @@ value_expr(node)
static NODE *cond2();
-static NODE*
-cond0(node)
- NODE *node;
-{
- enum node_type type = nd_type(node);
-
- switch (type) {
- case NODE_DREGX:
- case NODE_DREGX_ONCE:
- local_cnt('_');
- local_cnt('~');
- return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
-
- case NODE_DOT2:
- case NODE_DOT3:
- node->nd_beg = cond2(node->nd_beg);
- node->nd_end = cond2(node->nd_end);
- if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
- else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
- return node;
-
- case NODE_LIT:
- if (TYPE(node->nd_lit) == T_REGEXP) {
- local_cnt('_');
- local_cnt('~');
- return NEW_MATCH(node);
- }
- if (TYPE(node->nd_lit) == T_STRING) {
- local_cnt('_');
- local_cnt('~');
- return NEW_MATCH(reg_new(RSTRING(node)->ptr,RSTRING(node)->len,0));
- }
- default:
- return node;
- }
-}
-
int
assign_in_cond(node)
NODE *node;
@@ -3474,6 +3448,8 @@ assign_in_cond(node)
case NODE_IASGN:
case NODE_CASGN:
break;
+ case NODE_NEWLINE:
+
default:
return 1;
}
@@ -3500,12 +3476,48 @@ assign_in_cond(node)
}
static NODE*
-cond(node)
+cond0(node)
NODE *node;
{
enum node_type type = nd_type(node);
if (assign_in_cond(node) == 0) return 0;
+ switch (type) {
+ case NODE_DREGX:
+ case NODE_DREGX_ONCE:
+ local_cnt('_');
+ local_cnt('~');
+ return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
+
+ case NODE_DOT2:
+ case NODE_DOT3:
+ node->nd_beg = cond2(node->nd_beg);
+ node->nd_end = cond2(node->nd_end);
+ if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
+ else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
+ return node;
+
+ case NODE_LIT:
+ if (TYPE(node->nd_lit) == T_REGEXP) {
+ local_cnt('_');
+ local_cnt('~');
+ return NEW_MATCH(node);
+ }
+ if (TYPE(node->nd_lit) == T_STRING) {
+ local_cnt('_');
+ local_cnt('~');
+ return NEW_MATCH(reg_new(RSTRING(node)->ptr,RSTRING(node)->len,0));
+ }
+ default:
+ return node;
+ }
+}
+
+static NODE*
+cond(node)
+ NODE *node;
+{
+ if (node == 0) return 0;
if (nd_type(node) == NODE_NEWLINE){
node->nd_next = cond0(node->nd_next);
return node;
diff --git a/range.c b/range.c
index 121acfe..06fef09 100644
--- a/range.c
+++ b/range.c
@@ -18,8 +18,8 @@ extern VALUE cNumeric;
static ID upto;
static VALUE
-range_s_new(class, first, last)
- VALUE class, first, last;
+range_s_new(klass, first, last)
+ VALUE klass, first, last;
{
VALUE obj;
@@ -32,7 +32,7 @@ range_s_new(class, first, last)
ArgError("bad value for range");
}
- obj = obj_alloc(class);
+ obj = obj_alloc(klass);
rb_iv_set(obj, "first", first);
rb_iv_set(obj, "last", last);
diff --git a/re.c b/re.c
index 245bcbe..4669aea 100644
--- a/re.c
+++ b/re.c
@@ -625,8 +625,8 @@ Regexp *rp;
VALUE cRegexp;
static VALUE
-reg_new_1(class, s, len, flag)
- VALUE class;
+reg_new_1(klass, s, len, flag)
+ VALUE klass;
char *s;
int len;
int flag; /* CASEFOLD = 0x1 */
@@ -635,7 +635,7 @@ reg_new_1(class, s, len, flag)
/* CODE_SJIS = 0x6 */
{
NEWOBJ(re, struct RRegexp);
- OBJSETUP(re, class, T_REGEXP);
+ OBJSETUP(re, klass, T_REGEXP);
if (flag & 0x1) {
FL_SET(re, REG_IGNORECASE);
diff --git a/regex.c b/regex.c
index 152eebb..d9269fa 100644
--- a/regex.c
+++ b/regex.c
@@ -1748,7 +1748,7 @@ re_compile_pattern(pattern, size, bufp)
c1 = 0;
if (ismbchar(c)) {
c1 = c;
- PATFETCH(c);
+ PATFETCH_RAW(c);
}
else if (c > 0x7f) {
c1 = 0xff;
@@ -2418,7 +2418,7 @@ re_search(bufp, string, size, startpos, range, regs)
if (fastmap && startpos == size && range >= 0
&& (bufp->can_be_null == 0 ||
- (bufp->can_be_null == 2 && size > 0
+ (bufp->can_be_null && size > 0
&& string[startpos-1] == '\n')))
return -1;
@@ -3000,16 +3000,19 @@ re_match(bufp, string_arg, size, pos, regs)
break;
goto fail;
- /* Match at the very beginning of the string. */
+ /* Match at the very beginning of the string. */
case begbuf:
if (AT_STRINGS_BEG(d))
break;
goto fail;
- /* Match at the very end of the data. */
+ /* Match at the very end of the data. */
case endbuf:
if (AT_STRINGS_END(d))
break;
+ /* .. or newline just before the end of the data. */
+ if (*d == '\n' && AT_STRINGS_END(d+1))
+ break;
goto fail;
/* `or' constructs are handled by starting each alternative with
diff --git a/string.c b/string.c
index 972da1b..3c43e2d 100644
--- a/string.c
+++ b/string.c
@@ -156,12 +156,12 @@ str_dup(str)
}
static VALUE
-str_s_new(class, orig)
- VALUE class;
+str_s_new(klass, orig)
+ VALUE klass;
VALUE orig;
{
NEWOBJ(str, struct RString);
- OBJSETUP(str, class, T_STRING);
+ OBJSETUP(str, klass, T_STRING);
orig = obj_as_string(orig);
str->len = RSTRING(orig)->len;
@@ -897,12 +897,12 @@ str_sub_s(str, pat, val, once)
repl = reg_regsub(val, str, regs);
str_cat(result, RSTRING(repl)->ptr, RSTRING(repl)->len);
- if (END(0) == offset) {
+ if (BEG(0) == END(0)) {
/*
* Always consume at least one character of the input string
* in order to prevent infinite loops.
*/
- if (RSTRING(str)->len > 0) {
+ if (RSTRING(str)->len > END(0)) {
str_cat(result, RSTRING(str)->ptr+END(0), 1);
}
offset = END(0)+1;
diff --git a/struct.c b/struct.c
index 7234d1e..5220072 100644
--- a/struct.c
+++ b/struct.c
@@ -196,20 +196,20 @@ struct_s_def(argc, argv)
}
VALUE
-struct_alloc(class, values)
- VALUE class, values;
+struct_alloc(klass, values)
+ VALUE klass, values;
{
VALUE size;
int n;
- size = rb_iv_get(class, "__size__");
+ size = rb_iv_get(klass, "__size__");
n = FIX2INT(size);
if (n < RARRAY(values)->len) {
ArgError("struct size differs");
}
else {
NEWOBJ(st, struct RStruct);
- OBJSETUP(st, class, T_STRUCT);
+ OBJSETUP(st, klass, T_STRUCT);
st->len = n;
st->ptr = 0; /* avoid GC crashing */
st->ptr = ALLOC_N(VALUE, n);
@@ -222,15 +222,15 @@ struct_alloc(class, values)
}
VALUE
-struct_new(class, va_alist)
- VALUE class;
+struct_new(klass, va_alist)
+ VALUE klass;
va_dcl
{
VALUE val, mem;
int size;
va_list args;
- val = rb_iv_get(class, "__size__");
+ val = rb_iv_get(klass, "__size__");
size = FIX2INT(val);
mem = ary_new();
va_start(args);
@@ -240,7 +240,7 @@ struct_new(class, va_alist)
}
va_end(args);
- return struct_alloc(class, mem);
+ return struct_alloc(klass, mem);
}
static VALUE
diff --git a/time.c b/time.c
index eb3c003..a18cb96 100644
--- a/time.c
+++ b/time.c
@@ -50,13 +50,13 @@ struct time_object {
}
static VALUE
-time_s_now(class)
- VALUE class;
+time_s_now(klass)
+ VALUE klass;
{
VALUE obj;
struct time_object *tobj;
- obj = Data_Make_Struct(class, struct time_object, 0, 0, tobj);
+ obj = Data_Make_Struct(klass, struct time_object, 0, 0, tobj);
tobj->tm_got=0;
if (gettimeofday(&(tobj->tv), 0) == -1) {
@@ -67,14 +67,14 @@ time_s_now(class)
}
static VALUE
-time_new_internal(class, sec, usec)
- VALUE class;
+time_new_internal(klass, sec, usec)
+ VALUE klass;
int sec, usec;
{
VALUE obj;
struct time_object *tobj;
- obj = Data_Make_Struct(class, struct time_object, 0, 0, tobj);
+ obj = Data_Make_Struct(klass, struct time_object, 0, 0, tobj);
tobj->tm_got = 0;
tobj->tv.tv_sec = sec;
tobj->tv.tv_usec = usec;
@@ -135,13 +135,13 @@ time_timeval(time)
}
static VALUE
-time_s_at(class, time)
- VALUE class, time;
+time_s_at(klass, time)
+ VALUE klass, time;
{
struct timeval tv;
tv = time_timeval(time);
- return time_new_internal(class, tv.tv_sec, tv.tv_usec);
+ return time_new_internal(klass, tv.tv_sec, tv.tv_usec);
}
static char *months [12] = {
@@ -158,7 +158,17 @@ time_arg(argc, argv, args)
VALUE v[6];
int i;
- rb_scan_args(argc, argv, "15", &v[0], &v[1], &v[2], &v[3], &v[4], &v[5]);
+ if (argc == 10) {
+ v[0] = argv[5];
+ v[1] = argv[4];
+ v[2] = argv[3];
+ v[3] = argv[2];
+ v[4] = argv[1];
+ v[5] = argv[0];
+ }
+ else {
+ rb_scan_args(argc, argv, "15", &v[0],&v[1],&v[2],&v[3],&v[4],&v[5]);
+ }
args[0] = NUM2INT(v[0]);
if (args[0] < 70) args[0] += 100;
@@ -183,7 +193,7 @@ time_arg(argc, argv, args)
}
}
else {
- args[1] = NUM2INT(v[1]);
+ args[1] = NUM2INT(v[1]) - 1;
}
if (v[2] == Qnil) {
args[2] = 1;
@@ -211,11 +221,11 @@ time_arg(argc, argv, args)
}
static VALUE
-time_gm_or_local(argc, argv, gm_or_local, class)
+time_gm_or_local(argc, argv, gm_or_local, klass)
int argc;
VALUE *argv;
int gm_or_local;
- VALUE class;
+ VALUE klass;
{
int args[6];
struct timeval tv;
@@ -250,28 +260,28 @@ time_gm_or_local(argc, argv, gm_or_local, class)
guess += (args[4] - tm->tm_min) * 60;
guess += args[5] - tm->tm_sec;
- return time_new_internal(class, guess, 0);
+ return time_new_internal(klass, guess, 0);
error:
ArgError("gmtime/localtime error");
}
static VALUE
-time_s_timegm(argc, argv, class)
+time_s_timegm(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
- return time_gm_or_local(argc, argv, 1, class);
+ return time_gm_or_local(argc, argv, 1, klass);
}
static VALUE
-time_s_timelocal(argc, argv, class)
+time_s_timelocal(argc, argv, klass)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE klass;
{
- return time_gm_or_local(argc, argv, 0, class);
+ return time_gm_or_local(argc, argv, 0, klass);
}
static VALUE
@@ -576,6 +586,7 @@ time_mon(time)
if (tobj->tm_got == 0) {
time_localtime(time);
}
+ Warning("Time#month now start from 1 for January");
return INT2FIX(tobj->tm.tm_mon+1);
}
@@ -589,6 +600,7 @@ time_year(time)
if (tobj->tm_got == 0) {
time_localtime(time);
}
+ Warning("Time#year now returns 19xx");
return INT2FIX(tobj->tm.tm_year+1900);
}
@@ -628,7 +640,8 @@ time_isdst(time)
if (tobj->tm_got == 0) {
time_localtime(time);
}
- return INT2FIX(tobj->tm.tm_isdst);
+ Warning("Time#isdst now returns boolean value");
+ return tobj->tm.tm_isdst?TRUE:FALSE;
}
static VALUE
@@ -659,17 +672,18 @@ time_to_a(time)
if (tobj->tm_got == 0) {
time_localtime(time);
}
- ary = ary_new3(9,
- INT2FIX(tobj->tm.tm_sec),
- INT2FIX(tobj->tm.tm_min),
- INT2FIX(tobj->tm.tm_hour),
- INT2FIX(tobj->tm.tm_mday),
- INT2FIX(tobj->tm.tm_mon+1),
- INT2FIX(tobj->tm.tm_year+1900),
- INT2FIX(tobj->tm.tm_wday),
- INT2FIX(tobj->tm.tm_yday),
- INT2FIX(tobj->tm.tm_isdst));
- return ary;
+ Warning("Time#to_a's return values are now changed");
+ return ary_new3(10,
+ INT2FIX(tobj->tm.tm_sec),
+ INT2FIX(tobj->tm.tm_min),
+ INT2FIX(tobj->tm.tm_hour),
+ INT2FIX(tobj->tm.tm_mday),
+ INT2FIX(tobj->tm.tm_mon+1),
+ INT2FIX(tobj->tm.tm_year+1900),
+ INT2FIX(tobj->tm.tm_wday),
+ INT2FIX(tobj->tm.tm_yday),
+ tobj->tm.tm_isdst?TRUE:FALSE,
+ time_zone(time));
}
#define SMALLBUF 100
@@ -728,7 +742,7 @@ time_strftime(time, format)
}
len = rb_strftime(&buf, RSTRING(format)->ptr, &(tobj->tm));
str = str_new(buf, len);
- if (len > SMALLBUF) free(buf);
+ if (buf != buffer) free(buf);
return str;
}