diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-06-21 06:31:12 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-06-21 06:31:12 +0000 |
commit | 53838a0e58027072c1ea8617342c2137d9fa5313 (patch) | |
tree | fffefdd164a048925196a437c208c1b21f687bbb | |
parent | 7e774e049258dbda55edfdac9c5022c3d8fbdcf1 (diff) |
1.2.6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 57 | ||||
-rw-r--r-- | class.c | 5 | ||||
-rw-r--r-- | dln.c | 14 | ||||
-rw-r--r-- | eval.c | 7 | ||||
-rw-r--r-- | ext/etc/etc.c | 7 | ||||
-rw-r--r-- | ext/kconv/kconv.c | 39 | ||||
-rw-r--r-- | ext/tcltklib/extconf.rb | 4 | ||||
-rw-r--r-- | ext/tcltklib/tcltklib.c | 108 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tktext.rb | 175 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | lex.c | 149 | ||||
-rw-r--r-- | lib/getoptlong.rb | 4 | ||||
-rw-r--r-- | lib/mkmf.rb | 4 | ||||
-rw-r--r-- | object.c | 2 | ||||
-rw-r--r-- | pack.c | 107 | ||||
-rw-r--r-- | parse.y | 12 | ||||
-rw-r--r-- | regex.c | 4 | ||||
-rw-r--r-- | ruby.c | 2 | ||||
-rw-r--r-- | string.c | 67 | ||||
-rw-r--r-- | time.c | 1 | ||||
-rw-r--r-- | version.h | 2 |
22 files changed, 537 insertions, 240 deletions
@@ -1,3 +1,60 @@ +Mon Jun 21 15:29:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * version 1.2.6 (1.2 final) released. + +Fri Jun 11 15:21:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * ext/etc/etc.c (etc_group): dumps core if there's no more group. + +Thu Jun 10 16:41:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * eval.c (is_defined): `defined? super' should be true even for + private superclass methods. + +Mon Jun 7 23:23:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * object.c (mod_clone): should call CLOSESETUP(). + + * eval.c (bind_clone): should call CLONESETUP() for new clone. + +Wed Jun 2 00:41:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * pack.c (pack_unpack): new undocumented template Z which strips + stuff after first null. + + * pack.c (pack_pack): should preserve specified length of the + resulting string. + +Tue Jun 1 15:29:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * eval.c (module_setup): need to add PUSH_VAR/POP_VAR to clear + dyna vars link list. + +Tue May 25 16:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * io.c (rb_f_syscall): syscall may return values other than zero + on success. + +Tue May 18 11:35:59 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp> + + * dln.c (conv_to_posix_path): path_len argument added. + +Mon May 17 12:26:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * parse.y (read_escape): char may be unsigned. + + * string.c (rb_str_succ): ditto. + + * string.c (tr_trans): ditto. + + * regex.c (re_compile_pattern): escaped characters should be read + by PATFETCH_RAW(c). + +Sat May 15 11:23:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * class.c (include_class_new): should initialize iv_tbl to share + between module and iclass. + Wed May 12 14:19:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp> * struct.c (iv_get): in case of inheritance of generated struct @@ -198,8 +198,11 @@ include_class_new(module, super) NEWOBJ(klass, struct RClass); OBJSETUP(klass, cClass, T_ICLASS); - klass->m_tbl = RCLASS(module)->m_tbl; + if (!RCLASS(module)->iv_tbl) { + RCLASS(module)->iv_tbl = st_init_numtable(); + } klass->iv_tbl = RCLASS(module)->iv_tbl; + klass->m_tbl = RCLASS(module)->m_tbl; klass->super = super; if (TYPE(module) == T_ICLASS) { RBASIC(klass)->klass = RBASIC(module)->klass; @@ -1527,9 +1527,10 @@ dln_find_file(fname, path) #if defined(__CYGWIN32__) char * -conv_to_posix_path(win32, posix) +conv_to_posix_path(win32, posix, len) char *win32; char *posix; + int len; { char *first = win32; char *p = win32; @@ -1544,7 +1545,10 @@ conv_to_posix_path(win32, posix) first = p + 1; *p = ';'; } - cygwin32_conv_to_posix_path(first, posix); + if (len < strlen(first)) + fprintf(stderr, "PATH length too long: %s\n", first); + else + strcpy(posix, first); return dst; } #endif @@ -1563,8 +1567,10 @@ dln_find_1(fname, path, exe_flag) struct stat st; #if defined(__CYGWIN32__) - char rubypath[MAXPATHLEN]; - conv_to_posix_path(path, rubypath); + int pathlen = 2 * strlen(path); + int rubypathlen = pathlen > MAXPATHLEN ? pathlen : MAXPATHLEN; + char *rubypath = alloca(rubypathlen); + conv_to_posix_path(path, rubypath, rubypathlen); path = rubypath; #endif #ifndef __MACOS__ @@ -1392,7 +1392,7 @@ is_defined(self, node, buf) case NODE_ZSUPER: if (the_frame->last_func == 0) return 0; else if (rb_method_boundp(RCLASS(the_frame->last_class)->super, - the_frame->last_func, 1)) { + the_frame->last_func, 0)) { if (nd_type(node) == NODE_SUPER) { return arg_defined(self, node->nd_args, buf, "super"); } @@ -2671,6 +2671,7 @@ module_setup(module, node) PUSH_CLASS(); the_class = module; PUSH_SCOPE(); + PUSH_VARS(); if (node->nd_rval) the_frame->cbase = node->nd_rval; if (node->nd_tbl) { @@ -2694,6 +2695,7 @@ module_setup(module, node) result = rb_eval(the_class, node->nd_body); } POP_TAG(); + POP_VARS(); POP_SCOPE(); POP_CLASS(); @@ -4919,7 +4921,8 @@ bind_clone(self) VALUE bind; Data_Get_Struct(self, struct BLOCK, orig); - bind = Data_Make_Struct(self,struct BLOCK,blk_mark,blk_free,data); + bind = Data_Make_Struct(cBinding,struct BLOCK,blk_mark,blk_free,data); + CLONESETUP(bind, self); MEMCPY(data, orig, struct BLOCK, 1); data->frame.argv = ALLOC_N(VALUE, orig->frame.argc); MEMCPY(data->frame.argv, orig->frame.argv, VALUE, orig->frame.argc); diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 1cf06768c8..5e655980e4 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -214,10 +214,11 @@ etc_group(obj) endgrent(); return obj; } - return setup_group(getgrent()); -#else - return Qnil; + if (grp = getgrent()) { + return setup_group(grp); + } #endif + return Qnil; } static VALUE mEtc; diff --git a/ext/kconv/kconv.c b/ext/kconv/kconv.c index 0cb9b10a0b..048719b39f 100644 --- a/ext/kconv/kconv.c +++ b/ext/kconv/kconv.c @@ -165,8 +165,8 @@ static char *Patchlevel = /* MIME preprocessor */ -#define _GETC() (*inptr ? (int)(*inptr++) : EOF) -#define _UNGETC(c) (*--inptr = (c)) +#define _GETC() (inlen-- ? (int)(*inptr++) : EOF) +#define _UNGETC(c) (inlen++, *--inptr = (c)) #define PUTCHAR(c) (outlen + 1 < outsiz ? \ ((outptr[outlen++] = (c)), (outptr[outlen] = '\0')) : EOF) #define GETC() ((!mime_mode)?_GETC():mime_getc()) @@ -181,6 +181,7 @@ extern POINT _BufferSize; static unsigned char hold_buf[HOLD_SIZE*2]; static int hold_count; static unsigned char *inptr; +static int inlen; static char *outptr; static int outsiz; static int outlen; @@ -341,7 +342,7 @@ static int del_cr = FALSE; static void (*iconv) _((register int c2,register int c1)); /* s_iconv or oconv */ static void (*oconv) _((register int c2,register int c1)); /* [ejs]_oconv */ -static int do_kconv _((char *i, char *o, int siz, int out_code, int in_code)); +static int do_kconv _((VALUE, VALUE, int out_code, int in_code)); static void h_conv _((register int c2,register int c1)); static int push_hold_buf _((int c2,int c1)); static void s_iconv _((register int c2,register int c1)); @@ -580,25 +581,25 @@ main (argc, argv) #endif /* notdef */ static int -do_kconv(i, o, siz, out_code, in_code) - char *i; - char *o; - int siz, out_code, in_code; +do_kconv(in, out, out_code, in_code) + VALUE in, out; + int out_code, in_code; { - register int c1, - c2; + register int c1, c2; c2 = 0; - if (siz <= 0) { + inptr = (unsigned char *)RSTRING(in)->ptr; /* input buffer */ + inlen = RSTRING(in)->len; /* input buffer size*/ + outptr = RSTRING(out)->ptr; /* output buffer */ + outsiz = RSTRING(in)->len; /* output buffer size */ + outlen = 0; /* current length of output string */ + + if (inlen <= 0) { return 0; } - *o = '\0'; + *outptr = '\0'; - inptr = (unsigned char *)i; /* input buffer */ - outptr = o; /* output buffer */ - outsiz = siz; /* output buffer size */ - outlen = 0; /* current length of output string */ x0201_f = TRUE; /* don't assume JISX0201 kana */ rot_f = FALSE; /* rot14/43 mode */ input_f = FALSE; /* non fixed input code */ @@ -1834,7 +1835,7 @@ kconv_kconv(argc, argv) } dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ - RSTRING(dst)->len = do_kconv(RSTRING(src)->ptr, RSTRING(dst)->ptr, RSTRING(dst)->len, out_code, in_code); + RSTRING(dst)->len = do_kconv(src, dst, out_code, in_code); return dst; } @@ -1848,7 +1849,7 @@ kconv_tojis(obj, src) Check_Type(src, T_STRING); dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ - RSTRING(dst)->len = do_kconv(RSTRING(src)->ptr, RSTRING(dst)->ptr, RSTRING(dst)->len, _JIS, _AUTO); + RSTRING(dst)->len = do_kconv(src, dst, _JIS, _AUTO); return dst; } @@ -1862,7 +1863,7 @@ kconv_toeuc(obj, src) Check_Type(src, T_STRING); dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ - RSTRING(dst)->len = do_kconv(RSTRING(src)->ptr, RSTRING(dst)->ptr, RSTRING(dst)->len, _EUC, _AUTO); + RSTRING(dst)->len = do_kconv(src, dst, _EUC, _AUTO); return (VALUE)dst; } @@ -1876,7 +1877,7 @@ kconv_tosjis(obj, src) Check_Type(src, T_STRING); dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ - RSTRING(dst)->len = do_kconv(RSTRING(src)->ptr, RSTRING(dst)->ptr, RSTRING(dst)->len, _SJIS, _AUTO); + RSTRING(dst)->len = do_kconv(src, dst, _SJIS, _AUTO); return dst; } diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb index 6f6d256604..d206bf76ab 100644 --- a/ext/tcltklib/extconf.rb +++ b/ext/tcltklib/extconf.rb @@ -59,7 +59,7 @@ def search_lib(file, func, *path) for lib in files.sort!.reverse! lib = File::basename(lib) lib.sub!(/^lib/, '') - lib.sub!(/\.(a|so)$/, '') + lib.sub!(/\.(a|so(.[0-9]+)?)$/, '') if have_library(lib, func) unless $libraries.include? path $libraries << path @@ -74,7 +74,7 @@ def search_lib(file, func, *path) end if have_header("tcl.h") && have_header("tk.h") && - search_lib("libX11.{a,so}", "XOpenDisplay", + search_lib("libX11.{a,so*}", "XOpenDisplay", "/usr/lib", "/usr/openwin/lib", "/usr/X11*/lib") && search_lib("libtcl{,8*,7*}.{a,so}", "Tcl_FindExecutable", "/usr/lib", "/usr/local/lib") && diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 5948c8f5b0..3b464ecf28 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -27,8 +27,8 @@ fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); } */ /* for callback break & continue */ -VALUE eTkCallbackBreak; -VALUE eTkCallbackContinue; +static VALUE eTkCallbackBreak; +static VALUE eTkCallbackContinue; /* from tkAppInit.c */ @@ -49,15 +49,14 @@ typedef struct { } Tk_TimerData; /* timer callback */ -void _timer_for_tcl (ClientData clientData) +static void +_timer_for_tcl(clientData) + ClientData clientData; { Tk_TimerData *timer = (Tk_TimerData*)clientData; timer->flag = 0; CHECK_INTS; -#ifdef THREAD - if (!thread_critical) thread_schedule(); -#endif timer->token = Tk_CreateTimerHandler(200, _timer_for_tcl, (ClientData)timer); @@ -66,11 +65,12 @@ void _timer_for_tcl (ClientData clientData) /* execute Tk_MainLoop */ static VALUE -lib_mainloop(VALUE self) +lib_mainloop(self) + VALUE self; { Tk_TimerData *timer; - timer = (Tk_TimerData *) ckalloc(sizeof(Tk_TimerData)); + timer = (Tk_TimerData *)ALLOC(Tk_TimerData); timer->flag = 0; timer->token = Tk_CreateTimerHandler(200, _timer_for_tcl, (ClientData)timer); @@ -79,6 +79,7 @@ lib_mainloop(VALUE self) DUMP1("start Tk_Mainloop"); while (Tk_GetNumMainWindows() > 0) { Tcl_DoOneEvent(0); + CHECK_INTS; } DUMP1("stop Tk_Mainloop"); @@ -87,6 +88,7 @@ lib_mainloop(VALUE self) Tk_DeleteTimerHandler(timer->token); } #endif + free(timer); return Qnil; } @@ -99,7 +101,9 @@ struct tcltkip { /* Tcl command `ruby' */ static VALUE -ip_eval_rescue(VALUE *failed, VALUE einfo) +ip_eval_rescue(failed, einfo) + VALUE *failed; + VALUE einfo; { *failed = einfo; return Qnil; @@ -107,10 +111,17 @@ ip_eval_rescue(VALUE *failed, VALUE einfo) static int #if TCL_MAJOR_VERSION >= 8 -ip_ruby(ClientData clientData, Tcl_Interp *interp, - int argc, Tcl_Obj *CONST argv[]) +ip_ruby(clientData, interp, argc, argv) + ClientData clientData; + Tcl_Interp *interp; + int argc; + Tcl_Obj *CONST argv[]; #else -ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) +ip_ruby(clientData, interp, argc, argv) + ClientData clientData; + Tcl_Interp *interp; + int argc; + char *argv[]; #endif { VALUE res; @@ -167,7 +178,8 @@ ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) /* destroy interpreter */ static void -ip_free(struct tcltkip *ptr) +ip_free(ptr) + struct tcltkip *ptr; { DUMP1("Tcl_DeleteInterp"); Tcl_DeleteInterp(ptr->ip); @@ -176,7 +188,8 @@ ip_free(struct tcltkip *ptr) /* create and initialize interpreter */ static VALUE -ip_new(VALUE self) +ip_new(self) + VALUE self; { struct tcltkip *ptr; /* tcltkip data struct */ VALUE obj; /* newly created object */ @@ -218,7 +231,9 @@ ip_new(VALUE self) /* eval string in tcl by Tcl_Eval() */ static VALUE -ip_eval(VALUE self, VALUE str) +ip_eval(self, str) + VALUE self; + VALUE str; { char *s; char *buf; /* Tcl_Eval requires re-writable string region */ @@ -244,72 +259,74 @@ ip_eval(VALUE self, VALUE str) static VALUE -ip_toUTF8(VALUE self, VALUE str, VALUE encodename) +ip_toUTF8(self, str, encodename) + VALUE self; + VALUE str; + VALUE encodename; { -#ifndef TCL_UTF_MAX - return str; -#else +#ifdef TCL_UTF_MAX Tcl_Interp *interp; Tcl_Encoding encoding; Tcl_DString dstr; struct tcltkip *ptr; - char *buff1,*buff2; + char *buf; Data_Get_Struct(self,struct tcltkip, ptr); interp = ptr->ip; encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename)); - buff1 = ALLOCA_N(char,strlen(STR2CSTR(str))+1); - strcpy(buff1,STR2CSTR(str)); + buf = ALLOCA_N(char,strlen(STR2CSTR(str))+1); + strcpy(buf,STR2CSTR(str)); Tcl_DStringInit(&dstr); Tcl_DStringFree(&dstr); - Tcl_ExternalToUtfDString(encoding,buff1,strlen(buff1),&dstr); - buff2 = ALLOCA_N(char,Tcl_DStringLength(&dstr)+1); - strcpy(buff2,Tcl_DStringValue(&dstr)); + Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr); + str = str_new2(Tcl_DStringValue(&dstr)); Tcl_FreeEncoding(encoding); Tcl_DStringFree(&dstr); - - return str_new2(buff2); #endif + return str; } static VALUE -ip_fromUTF8(VALUE self, VALUE str, VALUE encodename) +ip_fromUTF8(self, str, encodename) + VALUE self; + VALUE str; + VALUE encodename; { -#ifndef TCL_UTF_MAX - return str; -#else +#ifdef TCL_UTF_MAX Tcl_Interp *interp; Tcl_Encoding encoding; Tcl_DString dstr; struct tcltkip *ptr; - char *buff1,*buff2; + char *buf; Data_Get_Struct(self,struct tcltkip, ptr); interp = ptr->ip; encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename)); - buff1 = ALLOCA_N(char,strlen(STR2CSTR(str))+1); - strcpy(buff1,STR2CSTR(str)); + buf = ALLOCA_N(char,strlen(STR2CSTR(str))+1); + strcpy(buf,STR2CSTR(str)); Tcl_DStringInit(&dstr); Tcl_DStringFree(&dstr); - Tcl_UtfToExternalDString(encoding,buff1,strlen(buff1),&dstr); - buff2 = ALLOCA_N(char,Tcl_DStringLength(&dstr)+1); - strcpy(buff2,Tcl_DStringValue(&dstr)); + Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr); + str = str_new2(Tcl_DStringValue(&dstr)); Tcl_FreeEncoding(encoding); Tcl_DStringFree(&dstr); - return str_new2(buff2); #endif + return str; } static VALUE -ip_invoke(int argc, VALUE *argv, VALUE obj) +ip_invoke(argc, argv, obj) + int argc; + VALUE *argv; + VALUE obj; { struct tcltkip *ptr; /* tcltkip data struct */ int i; @@ -344,6 +361,7 @@ ip_invoke(int argc, VALUE *argv, VALUE obj) for (i = 0; i < argc; ++i) { char *s = STR2CSTR(argv[i]); ov[i] = Tcl_NewStringObj(s, strlen(s)); + Tcl_IncrRefCount(ov[i]); } ov[argc] = (Tcl_Obj *)NULL; #endif @@ -372,6 +390,10 @@ ip_invoke(int argc, VALUE *argv, VALUE obj) resultPtr = Tcl_GetObjResult(ptr->ip); Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy), TCL_VOLATILE); + + for (i=0; i<argc; i++) { + Tcl_DecrRefCount(ov[i]); + } #endif } else { ptr->return_value = (*info.proc)(info.clientData, @@ -383,12 +405,13 @@ ip_invoke(int argc, VALUE *argv, VALUE obj) } /* pass back the result (as string) */ - return(str_new2(ptr->ip->result)); + return str_new2(ptr->ip->result); } /* get return code from Tcl_Eval() */ static VALUE -ip_retval(VALUE self) +ip_retval(self) + VALUE self; { struct tcltkip *ptr; /* tcltkip data struct */ @@ -408,7 +431,8 @@ _macinit() #endif /*---- initialization ----*/ -void Init_tcltklib() +void +Init_tcltklib() { extern VALUE rb_argv0; /* the argv[0] */ diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index e937e51c2b..0480d647b7 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -233,6 +233,7 @@ module TkComm return format("rb_out %s", id); end def uninstall_cmd(id) + id = $1 if /rb_out (c\d+)/ Tk_CMDTBL[id] = nil end private :install_cmd, :uninstall_cmd @@ -2115,7 +2116,7 @@ class TkScrollbar<TkWindow end def get - ary1 = tk_send('get', path).split + ary1 = tk_send('get').split ary2 = [] for i in ary1 ary2.push number(i) diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb index 02d5a7f3e0..8e07cf4347 100644 --- a/ext/tk/lib/tktext.rb +++ b/ext/tk/lib/tktext.rb @@ -247,11 +247,11 @@ class TkText<TkTextWin private :_tag_bind_core def tag_bind(tag, seq, cmd=Proc.new, args=nil) - _tag_bind_core('', tag, seq, cmd=Proc.new, args=nil) + _tag_bind_core('', tag, seq, cmd, args=nil) end def tag_bind_append(tag, seq, cmd=Proc.new, args=nil) - _tag_bind_core('+', tag, seq, cmd=Proc.new, args=nil) + _tag_bind_core('+', tag, seq, cmd, args=nil) end def tag_bindinfo(tag, context=nil) @@ -272,7 +272,7 @@ class TkText<TkTextWin end def tag_cget(tag, key) - tk_tcl2ruby tk_call @t.path, 'tag', 'cget', tag, "-#{key}" + tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}" end def tag_configure(tag, key, val=None) @@ -285,11 +285,11 @@ class TkText<TkTextWin end else - if ( key == 'font' || key == 'kanjifont' \ - || key == 'latinfont' || key == 'asciifont' ) + if key == 'font' || key == 'kanjifont' || + key == 'latinfont' || key == 'asciifont' tagfont_configure({key=>val}) else - tk_call 'tag', 'configure', tag, "-#{key}", val + tk_send 'tag', 'configure', tag, "-#{key}", val end end end @@ -320,7 +320,7 @@ class TkText<TkTextWin end def tag_ranges(tag) - l = tk_split_list(tk_send('tag', 'ranges', tag)) + l = tk_split_simplelist(tk_send('tag', 'ranges', tag)) r = [] while key=l.shift r.push [key, l.shift] @@ -329,11 +329,11 @@ class TkText<TkTextWin end def tag_nextrange(tag, first, last=None) - tk_split_list(tk_send('tag', 'nextrange', tag, first, last)) + tk_split_simplelist(tk_send('tag', 'nextrange', tag, first, last)) end def tag_prevrange(tag, first, last=None) - tk_split_list(tk_send('tag', 'prevrange', tag, first, last)) + tk_split_simplelist(tk_send('tag', 'prevrange', tag, first, last)) end def search_with_length(pat,start,stop=None) @@ -437,9 +437,19 @@ class TkTextTag<TkObject @path = @id = $tk_text_tag $tk_text_tag = $tk_text_tag.succ #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys) - configure(keys) if keys + if args != [] then + keys = args.pop + if keys.kind_of? Hash then + add(*args) if args != [] + configure(keys) + else + args.push keys + add(*args) + end + end @t._addtag id, self end + def id return @id end @@ -461,7 +471,7 @@ class TkTextTag<TkObject end def ranges - l = tk_split_list(tk_call(@t.path, 'tag', 'ranges', @id)) + l = tk_split_simplelist(tk_call(@t.path, 'tag', 'ranges', @id)) r = [] while key=l.shift r.push [key, l.shift] @@ -470,11 +480,11 @@ class TkTextTag<TkObject end def nextrange(first, last=None) - tk_split_list(tk_call(@t.path, 'tag', 'nextrange', @id, first, last)) + tk_split_simplelist(tk_call(@t.path, 'tag', 'nextrange', @id, first, last)) end def prevrange(first, last=None) - tk_split_list(tk_call(@t.path, 'tag', 'prevrange', @id, first, last)) + tk_split_simplelist(tk_call(@t.path, 'tag', 'prevrange', @id, first, last)) end def [](key) @@ -631,6 +641,18 @@ class TkTextMarkCurrent<TkTextMark end end +class TkTextMarkAnchor<TkTextMark + def initialize(parent,index=nil) + if not parent.kind_of?(TkText) + fail format("%s need to be TkText", parent.inspect) + end + @t = parent + @path = @id = 'anchor' + tk_call @t.path, 'mark', 'set', @id, index if index + @t._addtag id, self + end +end + class TkTextWindow<TkObject def initialize(parent, index, keys) if not parent.kind_of?(TkText) @@ -726,6 +748,133 @@ class TkTextWindow<TkObject } end end + + def _dump(type, *index) + str = tk_send('dump', type, *index) + result = [] + sel = nil + i = 0 + while i < str.size + # retrieve key + idx = str.index(/ /, i) + result.push str[i..(idx-1)] + i = idx + 1 + + # retrieve value + case result[-1] + when 'text' + if str[i] == ?{ + # text formed as {...} + val, i = _retrieve_braced_text(str, i) + result.push val + else + # text which may contain backslahes + val, i = _retrieve_backslashed_text(str, i) + result.push val + end + else + idx = str.index(/ /, i) + val = str[i..(idx-1)] + case result[-1] + when 'mark' + case val + when 'insert' + result.push TkTextMarkInsert.new(self) + when 'current' + result.push TkTextMarkCurrent.new(self) + when 'anchor' + result.push TkTextMarkAnchor.new(self) + else + result.push tk_tcl2rb(val) + end + when 'tagon' + if val == 'sel' + if sel + result.push sel + else + result.push TkTextTagSel.new(self) + end + else + result.push tk_tcl2rb val + end + when 'tagoff' + result.push tk_tcl2rb sel + when 'window' + result.push tk_tcl2rb val + end + i = idx + 1 + end + + # retrieve index + idx = str.index(/ /, i) + if idx + result.push str[i..(idx-1)] + i = idx + 1 + else + result.push str[i..-1] + break + end + end + + kvis = [] + until result.empty? + kvis.push [result.shift, result.shift, result.shift] + end + kvis # result is [[key1, value1, index1], [key2, value2, index2], ...] + end + private :_dump + + def _retrieve_braced_text(str, i) + cnt = 0 + idx = i + while idx < str.size + case str[idx] + when ?{ + cnt += 1 + when ?} + cnt -= 1 + if cnt == 0 + break + end + end + idx += 1 + end + return str[i+1..idx-1], idx + 2 + end + private :_retrieve_braced_text + + def _retrieve_backslashed_text(str, i) + j = i + idx = nil + loop { + idx = str.index(/ /, j) + if str[idx-1] == ?\\ + j += 1 + else + break + end + } + val = str[i..(idx-1)] + val.gsub!(/\\( |\{|\})/, '\1') + return val, idx + 1 + end + private :_retrieve_backslashed_text + + def dump_all(*index) + _dump('-all', *index) + end + def dump_mark(*index) + _dump('-mark', *index) + end + def dump_tag(*index) + _dump('-tag', *index) + end + def dump_text(*index) + _dump('-text', *index) + end + def dump_window(*index) + _dump('-window', *index) + end end class TkTextImage<TkObject @@ -2326,8 +2326,8 @@ f_syscall(argc, argv) #endif /* atarist */ } TRAP_END; - if (retval == -1) rb_sys_fail(0); - return INT2FIX(0); + if (retval < 0) rb_sys_fail(0); + return INT2NUM(retval); #else rb_notimplement(); #endif @@ -1,5 +1,5 @@ -/* C code produced by gperf version 2.5 (GNU C++ version) */ -/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ keywords */ +/* C code produced by gperf version 2.7.1 (19981006 egcs) */ +/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ ./keywords */ struct kwtable {char *name; int id[2]; enum lex_state state;}; #define TOTAL_KEYWORDS 40 @@ -10,28 +10,41 @@ struct kwtable {char *name; int id[2]; enum lex_state state;}; /* maximum key range = 50, duplicates = 0 */ #ifdef __GNUC__ -inline +__inline #endif static unsigned int hash (str, len) - register char *str; - register int unsigned len; + register const char *str; + register unsigned int len; { static unsigned char asso_values[] = { - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 11, 56, 56, 36, 56, 1, 37, - 31, 1, 56, 56, 56, 56, 29, 56, 1, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 1, 56, 32, 1, 2, - 1, 1, 4, 23, 56, 17, 56, 20, 9, 2, - 9, 26, 14, 56, 5, 1, 1, 16, 56, 21, - 20, 9, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 11, 56, 56, 36, 56, 1, 37, + 31, 1, 56, 56, 56, 56, 29, 56, 1, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 1, 56, 32, 1, 2, + 1, 1, 4, 23, 56, 17, 56, 20, 9, 2, + 9, 26, 14, 56, 5, 1, 1, 16, 56, 21, + 20, 9, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56 }; register int hval = len; @@ -39,68 +52,68 @@ hash (str, len) { default: case 3: - hval += asso_values[str[2]]; + hval += asso_values[(unsigned char)str[2]]; case 2: case 1: - hval += asso_values[str[0]]; + hval += asso_values[(unsigned char)str[0]]; break; } - return hval + asso_values[str[len - 1]]; + return hval + asso_values[(unsigned char)str[len - 1]]; } #ifdef __GNUC__ -inline +__inline #endif struct kwtable * rb_reserved_word (str, len) - register char *str; + register const char *str; register unsigned int len; { static struct kwtable wordlist[] = { - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, - {"end", kEND, kEND, EXPR_END}, - {"else", kELSE, kELSE, EXPR_BEG}, - {"case", kCASE, kCASE, EXPR_BEG}, - {"ensure", kENSURE, kENSURE, EXPR_BEG}, - {"module", kMODULE, kMODULE, EXPR_BEG}, - {"elsif", kELSIF, kELSIF, EXPR_BEG}, - {"def", kDEF, kDEF, EXPR_FNAME}, - {"rescue", kRESCUE, kRESCUE, EXPR_MID}, - {"not", kNOT, kNOT, EXPR_BEG}, - {"then", kTHEN, kTHEN, EXPR_BEG}, - {"yield", kYIELD, kYIELD, EXPR_END}, - {"for", kFOR, kFOR, EXPR_BEG}, - {"self", kSELF, kSELF, EXPR_END}, - {"false", kFALSE, kFALSE, EXPR_END}, - {"retry", kRETRY, kRETRY, EXPR_END}, - {"return", kRETURN, kRETURN, EXPR_MID}, - {"true", kTRUE, kTRUE, EXPR_END}, - {"if", kIF, kIF_MOD, EXPR_BEG}, - {"defined?", kDEFINED, kDEFINED, EXPR_END}, - {"super", kSUPER, kSUPER, EXPR_END}, - {"undef", kUNDEF, kUNDEF, EXPR_FNAME}, - {"break", kBREAK, kBREAK, EXPR_END}, - {"in", kIN, kIN, EXPR_BEG}, - {"do", kDO, kDO, EXPR_BEG}, - {"nil", kNIL, kNIL, EXPR_END}, - {"until", kUNTIL, kUNTIL_MOD, EXPR_BEG}, - {"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG}, - {"or", kOR, kOR, EXPR_BEG}, - {"next", kNEXT, kNEXT, EXPR_END}, - {"when", kWHEN, kWHEN, EXPR_BEG}, - {"redo", kREDO, kREDO, EXPR_END}, - {"and", kAND, kAND, EXPR_BEG}, - {"begin", kBEGIN, kBEGIN, EXPR_BEG}, - {"__LINE__", k__LINE__, k__LINE__, EXPR_END}, - {"class", kCLASS, kCLASS, EXPR_CLASS}, - {"__FILE__", k__FILE__, k__FILE__, EXPR_END}, - {"END", klEND, klEND, EXPR_END}, - {"BEGIN", klBEGIN, klBEGIN, EXPR_END}, - {"while", kWHILE, kWHILE_MOD, EXPR_BEG}, - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, - {"",}, - {"alias", kALIAS, kALIAS, EXPR_FNAME}, + {""}, {""}, {""}, {""}, {""}, {""}, + {"end", kEND, kEND, EXPR_END}, + {"else", kELSE, kELSE, EXPR_BEG}, + {"case", kCASE, kCASE, EXPR_BEG}, + {"ensure", kENSURE, kENSURE, EXPR_BEG}, + {"module", kMODULE, kMODULE, EXPR_BEG}, + {"elsif", kELSIF, kELSIF, EXPR_BEG}, + {"def", kDEF, kDEF, EXPR_FNAME}, + {"rescue", kRESCUE, kRESCUE, EXPR_MID}, + {"not", kNOT, kNOT, EXPR_BEG}, + {"then", kTHEN, kTHEN, EXPR_BEG}, + {"yield", kYIELD, kYIELD, EXPR_END}, + {"for", kFOR, kFOR, EXPR_BEG}, + {"self", kSELF, kSELF, EXPR_END}, + {"false", kFALSE, kFALSE, EXPR_END}, + {"retry", kRETRY, kRETRY, EXPR_END}, + {"return", kRETURN, kRETURN, EXPR_MID}, + {"true", kTRUE, kTRUE, EXPR_END}, + {"if", kIF, kIF_MOD, EXPR_BEG}, + {"defined?", kDEFINED, kDEFINED, EXPR_END}, + {"super", kSUPER, kSUPER, EXPR_END}, + {"undef", kUNDEF, kUNDEF, EXPR_FNAME}, + {"break", kBREAK, kBREAK, EXPR_END}, + {"in", kIN, kIN, EXPR_BEG}, + {"do", kDO, kDO, EXPR_BEG}, + {"nil", kNIL, kNIL, EXPR_END}, + {"until", kUNTIL, kUNTIL_MOD, EXPR_BEG}, + {"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG}, + {"or", kOR, kOR, EXPR_BEG}, + {"next", kNEXT, kNEXT, EXPR_END}, + {"when", kWHEN, kWHEN, EXPR_BEG}, + {"redo", kREDO, kREDO, EXPR_END}, + {"and", kAND, kAND, EXPR_BEG}, + {"begin", kBEGIN, kBEGIN, EXPR_BEG}, + {"__LINE__", k__LINE__, k__LINE__, EXPR_END}, + {"class", kCLASS, kCLASS, EXPR_CLASS}, + {"__FILE__", k__FILE__, k__FILE__, EXPR_END}, + {"END", klEND, klEND, EXPR_END}, + {"BEGIN", klBEGIN, klBEGIN, EXPR_END}, + {"while", kWHILE, kWHILE_MOD, EXPR_BEG}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, + {"alias", kALIAS, kALIAS, EXPR_FNAME} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) @@ -109,9 +122,9 @@ rb_reserved_word (str, len) if (key <= MAX_HASH_VALUE && key >= 0) { - register char *s = wordlist[key].name; + register const char *s = wordlist[key].name; - if (*s == *str && !strcmp (str + 1, s + 1)) + if (*str == *s && !strcmp (str + 1, s + 1)) return &wordlist[key]; } } diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb index 98a73ae3db..a37714cafd 100644 --- a/lib/getoptlong.rb +++ b/lib/getoptlong.rb @@ -75,7 +75,7 @@ class GetoptLong # # Whether error messages are output to stderr. # - @quiet_flag = FALSE + @quiet = FALSE # # Status code. @@ -259,7 +259,7 @@ class GetoptLong # Set an error (protected). # def set_error(type, message) - $stderr.print("#{$0}: #{message}\n") if !@quiet_flag + $stderr.print("#{$0}: #{message}\n") if !@quiet @error = type @error_message = message diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 218b3b19f6..b1744e3e0b 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -36,8 +36,8 @@ $archdir = $libdir+"/"+CONFIG["arch"] $install = CONFIG["INSTALL_PROGRAM"] $install_data = CONFIG["INSTALL_DATA"] if $install !~ /^\// then - $install = CONFIG["srcdir"]+"/"+$install - $install_data = CONFIG["srcdir"]+"/"+$install_data + $install = CONFIG["compile_dir"]+"/"+$install + $install_data = CONFIG["compile_dir"]+"/"+$install_data end if File.exist? $archdir + "/ruby.h" @@ -436,7 +436,7 @@ mod_clone(module) VALUE module; { NEWOBJ(clone, struct RClass); - OBJSETUP(clone, CLASS_OF(module), TYPE(module)); + CLONESETUP(clone, module); clone->super = RCLASS(module)->super; clone->iv_tbl = 0; @@ -138,9 +138,7 @@ pack_pack(ary, fmt) plen = 0; } else { - from = obj_as_string(from); - ptr = RSTRING(from)->ptr; - plen = RSTRING(from)->len; + ptr = str2cstr(from, &plen); } if (p[-1] == '*') @@ -149,6 +147,7 @@ pack_pack(ary, fmt) switch (type) { case 'a': case 'A': + case 'Z': if (plen >= len) str_cat(res, ptr, len); else { @@ -165,8 +164,12 @@ pack_pack(ary, fmt) case 'b': { int byte = 0; - int i; + int i, j; + if (len > plen) { + j = (len - plen + 1)/2; + len = plen; + } for (i=0; i++ < len; ptr++) { if (*ptr & 1) byte |= 128; @@ -184,14 +187,21 @@ pack_pack(ary, fmt) c = byte & 0xff; str_cat(res, &c, 1); } + len = RSTRING(res)->len; + str_resize(res, len+j); + MEMZERO(RSTRING(res)->ptr+len, char, j); } break; case 'B': { int byte = 0; - int i; + int i, j; + if (len > plen) { + j = (len - plen + 1)/2; + len = plen; + } for (i=0; i++ < len; ptr++) { byte |= *ptr & 1; if (i & 7) @@ -208,60 +218,73 @@ pack_pack(ary, fmt) c = byte & 0xff; str_cat(res, &c, 1); } + len = RSTRING(res)->len; + str_resize(res, len+j); + MEMZERO(RSTRING(res)->ptr+len, char, j); } break; case 'h': { int byte = 0; - int i; + int i, j; + if (len > plen) { + j = (len - plen + 1)/2; + len = plen; + } for (i=0; i++ < len; ptr++) { - if (ISXDIGIT(*ptr)) { - if (ISALPHA(*ptr)) - byte |= (((*ptr & 15) + 9) & 15) << 4; - else - byte |= (*ptr & 15) << 4; - if (i & 1) - byte >>= 4; - else { - char c = byte & 0xff; - str_cat(res, &c, 1); - byte = 0; - } + if (ISALPHA(*ptr)) + byte |= (((*ptr & 15) + 9) & 15) << 4; + else + byte |= (*ptr & 15) << 4; + if (i & 1) + byte >>= 4; + else { + char c = byte & 0xff; + str_cat(res, &c, 1); + byte = 0; } } if (len & 1) { char c = byte & 0xff; str_cat(res, &c, 1); } + len = RSTRING(res)->len; + str_resize(res, len+j); + MEMZERO(RSTRING(res)->ptr+len, char, j); } break; case 'H': { int byte = 0; - int i; + int i, j; + if (len > plen) { + j = (len - plen + 1)/2; + len = plen; + } for (i=0; i++ < len; ptr++) { - if (ISXDIGIT(*ptr)) { - if (ISALPHA(*ptr)) - byte |= ((*ptr & 15) + 9) & 15; - else - byte |= *ptr & 15; - if (i & 1) - byte <<= 4; - else { - char c = byte & 0xff; - str_cat(res, &c, 1); - byte = 0; - } + if (ISALPHA(*ptr)) + byte |= ((*ptr & 15) + 9) & 15; + else + byte |= *ptr & 15; + if (i & 1) + byte <<= 4; + else { + char c = byte & 0xff; + str_cat(res, &c, 1); + byte = 0; } } if (len & 1) { char c = byte & 0xff; str_cat(res, &c, 1); } + len = RSTRING(res)->len; + str_resize(res, len+j); + MEMZERO(RSTRING(res)->ptr+len, char, j); } break; } @@ -449,9 +472,7 @@ pack_pack(ary, fmt) case 'u': case 'm': - from = obj_as_string(NEXTFROM); - ptr = RSTRING(from)->ptr; - plen = RSTRING(from)->len; + ptr = str2cstr(NEXTFROM, &plen); if (len <= 1) len = 45; @@ -673,8 +694,22 @@ pack_unpack(str, fmt) while (t >= s) { if (*t != ' ' && *t != '\0') break; - t--; - len--; + t--; len--; + } + ary_push(ary, str_new(s, len)); + s += end; + } + break; + + case 'Z': + if (len > send - s) len = send - s; + { + int end = len; + char *t = s + len - 1; + + while (t >= s) { + if (*t) break; + t--; len--; } ary_push(ary, str_new(s, len)); s += end; @@ -19,11 +19,6 @@ #include "st.h" #include <stdio.h> -/* hack for bison */ -#ifdef const -# undef const -#endif - #define ID_SCOPE_SHIFT 3 #define ID_SCOPE_MASK 0x07 #define ID_LOCAL 0x01 @@ -1835,8 +1830,9 @@ read_escape() int i; for (i=0; i<2; i++) { - buf[i] = nextc(); - if (buf[i] == -1) goto eof; + int cc = nextc(); + if (cc == -1) goto eof; + buf[i] = cc; if (!ISXDIGIT(buf[i])) { pushback(buf[i]); break; @@ -3249,6 +3245,8 @@ str_extend(list, term) newtok(); return list; } + tokadd(c); + break; case '\n': sourceline++; default: @@ -49,7 +49,7 @@ void *xcalloc P((unsigned long,unsigned long)); void *xrealloc P((void*,unsigned long)); void free P((void*)); -/* #define NO_ALLOCA /* try it out for now */ +/* #define NO_ALLOCA */ /* try it out for now */ #ifndef NO_ALLOCA /* Make alloca work the best possible way. */ #ifdef __GNUC__ @@ -1245,7 +1245,7 @@ re_compile_pattern(pattern, size, bufp) /* \ escapes characters when inside [...]. */ if (c == '\\') { - PATFETCH(c); + PATFETCH_RAW(c); switch (c) { case 'w': for (c = 0; c < (1 << BYTEWIDTH); c++) { @@ -107,7 +107,7 @@ addpath(path) #if defined(__CYGWIN32__) { char rubylib[FILENAME_MAX]; - conv_to_posix_path(path, rubylib); + conv_to_posix_path(path, rubylib, FILENAME_MAX); path = rubylib; } #endif @@ -725,7 +725,7 @@ str_succ(orig) { VALUE str, str2; char *sbeg, *s; - char c = -1; + int c = -1; str = str_new(RSTRING(orig)->ptr, RSTRING(orig)->len); @@ -1169,7 +1169,7 @@ str_sub(argc, argv, str) else { v = str_sub_s(str, pat, val, 1); } - if (NIL_P(v)) return str_dup(str); + if (NIL_P(v)) return str; return v; } @@ -1201,7 +1201,7 @@ str_gsub(argc, argv, str) else { v = str_sub_s(str, pat, val, 0); } - if (NIL_P(v)) return str_dup(str); + if (NIL_P(v)) return str; return v; } @@ -1294,10 +1294,12 @@ f_gsub(argc, argv) else { v = str_sub_s(line, pat, val, 0); } - if (NIL_P(v)) v = str_dup(line); - lastline_set(v); + if (!NIL_P(v)) { + lastline_set(v); + line = v; + } - return v; + return line; } static VALUE @@ -1592,7 +1594,7 @@ static VALUE str_upcase(str) VALUE str; { - VALUE val = str_upcase_bang(str = str_dup(str)); + VALUE val = str_upcase_bang(str_dup(str)); if (NIL_P(val)) return str; return val; @@ -1626,7 +1628,7 @@ static VALUE str_downcase(str) VALUE str; { - VALUE val = str_downcase_bang(str = str_dup(str)); + VALUE val = str_downcase_bang(str_dup(str)); if (NIL_P(val)) return str; return val; @@ -1662,7 +1664,7 @@ static VALUE str_capitalize(str) VALUE str; { - VALUE val = str_capitalize_bang(str = str_dup(str)); + VALUE val = str_capitalize_bang(str_dup(str)); if (NIL_P(val)) return str; return val; @@ -1700,7 +1702,7 @@ static VALUE str_swapcase(str) VALUE str; { - VALUE val = str_swapcase_bang(str = str_dup(str)); + VALUE val = str_swapcase_bang(str_dup(str)); if (NIL_P(val)) return str; return val; @@ -1753,7 +1755,7 @@ tr_trans(str, src, repl, sflag) { struct tr trsrc, trrepl; int cflag = 0; - char trans[256]; + int trans[256]; int i, c, modify = 0; char *s, *send; @@ -1765,7 +1767,9 @@ tr_trans(str, src, repl, sflag) trsrc.p++; } if (TYPE(repl) != T_STRING) repl = str_to_str(repl); - if (RSTRING(repl)->len == 0) return str_delete_bang(str, src); + if (RSTRING(repl)->len == 0) { + return str_delete_bang(str, src); + } trrepl.p = RSTRING(repl)->ptr; trrepl.pend = trrepl.p + RSTRING(repl)->len; trsrc.gen = trrepl.gen = 0; @@ -1777,21 +1781,21 @@ tr_trans(str, src, repl, sflag) trans[i] = 1; } while ((c = trnext(&trsrc)) >= 0) { - trans[c & 0xff] = 0; + trans[c & 0xff] = -1; } while ((c = trnext(&trrepl)) >= 0) /* retrieve last replacer */; for (i=0; i<256; i++) { - if (trans[i] != 0) { + if (trans[i] >= 0) { trans[i] = trrepl.now; } } } else { - char r; + int r; for (i=0; i<256; i++) { - trans[i] = 0; + trans[i] = -1; } while ((c = trnext(&trsrc)) >= 0) { r = trnext(&trrepl); @@ -1807,10 +1811,10 @@ tr_trans(str, src, repl, sflag) while (s < send) { c0 = *s++; - if ((c = trans[c0 & 0xff] & 0xff) != 0) { + if ((c = trans[c0 & 0xff]) >= 0) { if (last == c) continue; last = c; - *t++ = c; + *t++ = c & 0xff; modify = 1; } else { @@ -1826,10 +1830,11 @@ tr_trans(str, src, repl, sflag) } else { while (s < send) { - if ((c = trans[*s++ & 0xff] & 0xff) != 0) { - *s = c; + if ((c = trans[*s & 0xff]) >= 0) { + *s = c & 0xff; modify = 1; } + s++; } } @@ -1848,7 +1853,7 @@ static VALUE str_tr(str, src, repl) VALUE str, src, repl; { - VALUE val = tr_trans(str = str_dup(str), src, repl, 0); + VALUE val = tr_trans(str_dup(str), src, repl, 0); if (NIL_P(val)) return str; return val; @@ -1911,7 +1916,7 @@ static VALUE str_delete(str1, str2) VALUE str1, str2; { - VALUE val = str_delete_bang(str1 = str_dup(str1), str2); + VALUE val = str_delete_bang(str_dup(str1), str2); if (NIL_P(val)) return str1; return val; @@ -1978,7 +1983,7 @@ str_squeeze(argc, argv, str) VALUE *argv; VALUE str; { - VALUE val = str_squeeze_bang(argc, argv, str = str_dup(str)); + VALUE val = str_squeeze_bang(argc, argv, str_dup(str)); if (NIL_P(val)) return str; return val; @@ -1995,7 +2000,7 @@ static VALUE str_tr_s(str, src, repl) VALUE str, src, repl; { - VALUE val = tr_trans(str = str_dup(str), src, repl, 1); + VALUE val = tr_trans(str_dup(str), src, repl, 1); if (NIL_P(val)) return str; return val; @@ -2255,7 +2260,7 @@ static VALUE str_chop(str) VALUE str; { - VALUE val = str_chop_bang(str = str_dup(str)); + VALUE val = str_chop_bang(str_dup(str)); if (NIL_P(val)) return str; return val; @@ -2271,10 +2276,10 @@ f_chop_bang(str) static VALUE f_chop() { - VALUE str = str_dup(uscore_get()); + VALUE str = uscore_get(); VALUE val; - val = str_chop_bang(str); + val = str_chop_bang(str_dup(str)); if (NIL_P(val)) return str; lastline_set(val); return val; @@ -2329,7 +2334,7 @@ str_chomp(argc, argv, str) VALUE *argv; VALUE str; { - VALUE val = str_chomp_bang(argc, argv, str = str_dup(str)); + VALUE val = str_chomp_bang(argc, argv, str_dup(str)); if (NIL_P(val)) return str; return val; @@ -2348,8 +2353,8 @@ f_chomp(argc, argv) int argc; VALUE *argv; { - VALUE str = str_dup(uscore_get()); - VALUE val = str_chomp_bang(argc, argv, str); + VALUE str = uscore_get(); + VALUE val = str_chomp_bang(argc, argv, str_dup(str)); if (NIL_P(val)) return str; lastline_set(val); @@ -2396,7 +2401,7 @@ static VALUE str_strip(str) VALUE str; { - VALUE val = str_strip_bang(str = str_dup(str)); + VALUE val = str_strip_bang(str_dup(str)); if (NIL_P(val)) return str; return val; @@ -873,6 +873,7 @@ Init_Time() rb_define_method(cTime, "<=>", time_cmp, 1); rb_define_method(cTime, "eql?", time_eql, 1); rb_define_method(cTime, "hash", time_hash, 0); + rb_define_method(cTime, "clone", time_clone, 0); rb_define_method(cTime, "localtime", time_localtime, 0); rb_define_method(cTime, "gmtime", time_gmtime, 0); @@ -1,2 +1,2 @@ #define RUBY_VERSION "1.2.6" -#define VERSION_DATE "99/05/12" +#define VERSION_DATE "99/06/21" |