diff options
64 files changed, 122 insertions, 33 deletions
@@ -6,7 +6,7 @@ $Date$ created at: Thu Mar 31 12:21:29 JST 1994 - Copyright (C) 1993-2001 Yukihiro Matsumoto ************************************************/ @@ -13,7 +13,7 @@ **********************************************************************/ #include "ruby.h" -#include "rubyio.h" #if defined(HAVE_FCNTL_H) || defined(_WIN32) #include <fcntl.h> #elif defined(HAVE_SYS_FCNTL_H) @@ -84,6 +84,18 @@ get_strio(VALUE self) return ptr; } #define StringIO(obj) get_strio(obj) #define CLOSED(ptr) (!((ptr)->flags & FMODE_READWRITE)) @@ -603,7 +615,7 @@ strio_each_byte(VALUE self) /* * call-seq: - * strio.getc -> fixnum or nil * * See IO#getc. */ @@ -611,15 +623,17 @@ static VALUE strio_getc(VALUE self) { struct StringIO *ptr = readable(StringIO(self)); - int c; - char ch; if (ptr->pos >= RSTRING_LEN(ptr->string)) { return Qnil; } - c = RSTRING_PTR(ptr->string)[ptr->pos++]; - ch = c & 0xff; - return rb_str_new(&ch, 1); } /* @@ -671,30 +685,34 @@ static VALUE strio_ungetc(VALUE self, VALUE c) { struct StringIO *ptr = readable(StringIO(self)); - int cc; - long len, pos = ptr->pos; if (NIL_P(c)) return Qnil; if (FIXNUM_P(c)) { - cc = FIX2INT(c); } else { SafeStringValue(c); - if (RSTRING_LEN(c) > 1) { - rb_warn("IO#ungetc pushes back only one byte"); - } - cc = (unsigned char)RSTRING_PTR(c)[0]; } - if (cc != EOF && pos > 0) { - if ((len = RSTRING_LEN(ptr->string)) < pos-- || - (unsigned char)RSTRING_PTR(ptr->string)[pos] != - (unsigned char)cc) { - strio_extend(ptr, pos, 1); - RSTRING_PTR(ptr->string)[pos] = cc; - OBJ_INFECT(ptr->string, self); - } - --ptr->pos; } return Qnil; } @@ -800,7 +818,7 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr) e = s + limit; } if (NIL_P(str)) { - str = rb_str_substr(ptr->string, ptr->pos, e - s); } else if ((n = RSTRING_LEN(str)) == 0) { p = s; @@ -816,13 +834,13 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr) break; } } - str = rb_str_substr(ptr->string, s - RSTRING_PTR(ptr->string), e - s); } else if (n == 1) { if ((p = memchr(s, RSTRING_PTR(str)[0], e - s)) != 0) { e = p + 1; } - str = rb_str_substr(ptr->string, ptr->pos, e - s); } else { if (n < e - s) { @@ -843,7 +861,7 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr) } } } - str = rb_str_substr(ptr->string, ptr->pos, e - s); } ptr->pos = e - RSTRING_PTR(ptr->string); ptr->lineno++; @@ -944,7 +962,7 @@ strio_write(VALUE self, VALUE str) if (TYPE(str) != T_STRING) str = rb_obj_as_string(str); len = RSTRING_LEN(str); - if (!len) return INT2FIX(0); check_modifiable(ptr); olen = RSTRING_LEN(ptr->string); if (ptr->flags & FMODE_APPEND) { @@ -955,7 +973,8 @@ strio_write(VALUE self, VALUE str) } else { strio_extend(ptr, ptr->pos, len); - rb_str_update(ptr->string, ptr->pos, len, str); } OBJ_INFECT(ptr->string, self); ptr->pos += len; @@ -1070,7 +1089,7 @@ strio_read(int argc, VALUE *argv, VALUE self) rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc); } if (NIL_P(str)) { - str = rb_str_substr(ptr->string, ptr->pos, len); } else { long rest = RSTRING_LEN(ptr->string) - ptr->pos; @@ -10,6 +10,7 @@ #include "ruby/ruby.h" #include "ruby/re.h" #define STRSCAN_VERSION "0.7.0" @@ -189,6 +190,7 @@ strscan_initialize(int argc, VALUE *argv, VALUE self) rb_scan_args(argc, argv, "11", &str, &need_dup); StringValue(str); p->str = str; return self; } @@ -652,13 +654,14 @@ strscan_getch(VALUE self) { struct strscanner *p; long len; GET_SCANNER(self, p); CLEAR_MATCH_STATUS(p); if (EOS_P(p)) return Qnil; - len = mbclen(*CURPTR(p)); if (p->curr + len > S_LEN(p)) { len = S_LEN(p) - p->curr; } @@ -7,7 +7,7 @@ * Copyright (C) 2003 why the lucky stiff * * All Base64 code from Ruby's pack.c. - * Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto */ #include "ruby/ruby.h" @@ -1,3 +1,4 @@ # # animated label widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # animated wave demo (called by 'widget') # @@ -1,3 +1,4 @@ # # arrowhead widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # text (tag bindings) widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # bitmap widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # button widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # checkbutton widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # checkbutton widget demo2 (called by 'widget') # @@ -1,3 +1,4 @@ # # widget demo prompts the user to select a color (called by 'widget') # @@ -1,3 +1,4 @@ # # listbox widget demo 'colors' (called by 'widget') # @@ -1,3 +1,4 @@ # # simple scrollable canvas widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # Canvas Text widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # a dialog box with a local grab (called by 'widget') # @@ -1,3 +1,4 @@ # # a dialog box with a global grab (called by 'widget') # @@ -1,3 +1,4 @@ # # entry (no scrollbars) widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # entry (with scrollbars) widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # entry3.rb -- # # This demonstration script creates several entry widgets whose @@ -1,3 +1,4 @@ # # widget demo prompts the user to select a file (called by 'widget') # @@ -1,3 +1,4 @@ # # floorDisplay widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # floorDisplay widget demo 2 (called by 'widget') # @@ -1,3 +1,4 @@ # # form widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # Ruby/Tk Goldverg demo (called by 'widget') # @@ -1,4 +1,5 @@ #!/usr/bin/env ruby require 'tk' TkButton.new(nil, @@ -1,3 +1,4 @@ require "tkcanvas" if defined?($hscale_demo) && $hscale_deom @@ -1,3 +1,4 @@ # # iconic button widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # two image widgets demo (called by 'widget') # @@ -1,3 +1,4 @@ # # widget demo 'load image' (called by 'widget') # @@ -1,3 +1,4 @@ # image3.rb # # This demonstration script creates a simple collection of widgets @@ -1,3 +1,4 @@ # # canvas item types widget demo (called by 'widget') # @@ -1,4 +1,5 @@ #!/usr/bin/env ruby # # ixset -- # A nice interface to "xset" to change X server settings @@ -1,3 +1,4 @@ # # label widget demo (called by 'widget') # @@ -1,3 +1,5 @@ # labelframe.rb # # This demonstration script creates a toplevel window containing @@ -1,3 +1,4 @@ # # menus widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # menus widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # menus widget demo (called by 'widget') # @@ -1,3 +1,4 @@ require "tkcanvas" def optionMenu(menubutton, varName, firstValue, *rest) @@ -1,3 +1,4 @@ # # message boxes widget demo (called by 'widget') # @@ -1,3 +1,5 @@ # paned1.rb # # This demonstration script creates a toplevel window containing @@ -1,3 +1,5 @@ # paned2.rb -- # # This demonstration script creates a toplevel window containing @@ -1,3 +1,4 @@ # # This demonstration illustrates how Tcl/Tk can be used to construct # simulations of physical systems. @@ -1,3 +1,4 @@ # # 2-D plot widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # widet demo 'puzzle' (called by 'widget') # @@ -1,3 +1,4 @@ # # radiobutton widget demo (called by 'widget') # @@ -1,3 +1,5 @@ # radio2.rb # # This demonstration script creates a toplevel window containing @@ -1,3 +1,5 @@ # radio3.rb # # This demonstration script creates a toplevel window containing @@ -1,4 +1,5 @@ #!/usr/bin/env ruby # # rolodex -- # ���Υ�����ץȤ� Tom LaStrange �� rolodex �ΰ����Ǥ��� @@ -1,3 +1,4 @@ # # ruler widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # listbox widget demo 'sayings' (called by 'widget') # @@ -1,3 +1,4 @@ # # Text Search widget demo (called by 'widget') # @@ -1,3 +1,5 @@ # spin.rb -- # # This demonstration script creates several spinbox widgets. @@ -1,3 +1,4 @@ # # listbox widget demo 'states' (called by 'widget') # @@ -1,3 +1,4 @@ # # text (display styles) widget demo (called by 'widget') # @@ -1,4 +1,5 @@ #!/usr/bin/env ruby # # tcolor -- # ���Υ�����ץȤ�RGB,HSB,CYM�����ݡ��Ȥ��� @@ -1,3 +1,4 @@ # # text (basic facilities) widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # text (embedded windows) widget demo (called by 'widget') # @@ -1,3 +1,4 @@ # # text (embedded windows) widget demo 2 (called by 'widget') # @@ -1,3 +1,5 @@ # unicodeout.rb -- # # This demonstration script shows how you can produce output (in label @@ -1,3 +1,4 @@ require "tkcanvas" if defined?($vscale_demo) && $vscale_demo @@ -1,4 +1,5 @@ #!/usr/bin/env ruby # �������������� ( tk.rb �Υ����ɻ��� encoding ����/����˻Ȥ��� ) $KCODE = 'euc' @@ -1,4 +1,5 @@ #!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' |