[前][次][番号順一覧][スレッド一覧]

ruby-changes:7433

From: nobu <ko1@a...>
Date: Sat, 30 Aug 2008 20:12:46 +0900 (JST)
Subject: [ruby-changes:7433] Ruby:r18952 (mvm): * merged from trunk r18938:18951.

nobu	2008-08-30 20:09:33 +0900 (Sat, 30 Aug 2008)

  New Revision: 18952

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18952

  Log:
    * merged from trunk r18938:18951.

  Modified files:
    branches/mvm/.merged-trunk-revision
    branches/mvm/ChangeLog
    branches/mvm/ext/dl/mkcallback.rb
    branches/mvm/ext/openssl/ossl_config.c
    branches/mvm/ext/openssl/ossl_x509ext.c
    branches/mvm/ext/strscan/strscan.c
    branches/mvm/parse.y
    branches/mvm/win32/win32.c

Index: mvm/ChangeLog
===================================================================
--- mvm/ChangeLog	(revision 18951)
+++ mvm/ChangeLog	(revision 18952)
@@ -15,6 +15,24 @@
 	* vm.c (th_init2, thread_free): initializes and destroys signal and
 	  message queues.
 
+Sat Aug 30 20:05:41 2008  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_open, rb_w32_read, rb_w32_write): fallback to
+	  MSVCRT if text mode is specified. this case will not be used from
+	  ruby itself.
+
+Sat Aug 30 19:49:38 2008  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_read): EOF is not error.
+	  ref [ruby-dev:36050]
+
+Sat Aug 30 18:17:40 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (struct token_info): constified.
+
+	* parse.y (token_info_get_column, token_info_has_nonspaces),
+	  (token_info_push, token_info_pop): constified.
+
 Sat Aug 30 16:38:23 2008    <nobu@r...>
 
 	* vm_core.h (struct rb_vm_struct): replaced signal staff with trap
@@ -33,6 +51,36 @@
 
 	* vm.c (rb_vm_mark): marks trap_list.
 
+Sat Aug 30 15:43:03 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* ext/openssl/ossl_config.c (Init_ossl_config): memory leak fixed.
+	  a patch <shinichiro.hamaji at gmail.com> in [ruby-dev:35880].
+
+	* ext/openssl/ossl_x509ext.c (ossl_x509ext_set_value): ditto.
+
+	* ext/strscan/strscan.c (strscan_do_scan): ditto.
+
+Sat Aug 30 14:58:32 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/openssl/ossl_x509ext.c (ossl_x509ext_initialize): fix for
+	  initialization of r18168.
+
+Sat Aug 30 14:47:30 2008  Tanaka Akira  <akr@f...>
+
+	* ext/dl/mkcallback.rb: fix continuation line detection.
+
+Sat Aug 30 14:39:51 2008  Tanaka Akira  <akr@f...>
+
+	* ext/dl/mkcallback.rb (rb_dl_init_callbacks): avoid GC problem which
+	  is caused by 'GC.stress=true; require "dl"'.
+
+Sat Aug 30 11:54:17 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* parse.y (token_info_push): -w warns indentation level mismatch.
+	  based on a patch from Yukina Yamano presented at RubyKaigi'07.
+	  See <http://jp.rubyist.net/RubyKaigi2007/Log0609-LT06.html> and
+	  <http://www.logic-junction.com/products/rubyend.html> (Japanese).
+
 Sat Aug 30 10:46:44 2008  Koichi Sasada  <ko1@a...>
 
 	* ext/iconv/iconv.c: remove include pragma for "ruby/intern.h".
Index: mvm/win32/win32.c
===================================================================
--- mvm/win32/win32.c	(revision 18951)
+++ mvm/win32/win32.c	(revision 18952)
@@ -4007,6 +4007,15 @@
     SECURITY_ATTRIBUTES sec;
     HANDLE h;
 
+    if ((oflag & O_TEXT) || !(oflag & ~O_BINARY)) {
+	va_list arg;
+	int pmode;
+	va_start(arg, oflag);
+	pmode = va_arg(arg, int);
+	va_end(arg);
+	return _open(file, oflag, pmode);
+    }
+
     sec.nLength = sizeof(sec);
     sec.lpSecurityDescriptor = NULL;
     if (oflag & O_NOINHERIT) {
@@ -4313,6 +4322,10 @@
 	return -1;
     }
 
+    if (_osfile(fd) & FTEXT) {
+	return _read(fd, buf, size);
+    }
+
     MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock)));
 
     if (!size || _osfile(fd) & FEOFLAG) {
@@ -4353,7 +4366,7 @@
 	if (err != ERROR_IO_PENDING) {
 	    if (err == ERROR_ACCESS_DENIED)
 		errno = EBADF;
-	    else if (err == ERROR_BROKEN_PIPE) {
+	    else if (err == ERROR_BROKEN_PIPE || err == ERROR_HANDLE_EOF) {
 		MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
 		return 0;
 	    }
@@ -4423,6 +4436,10 @@
 	return -1;
     }
 
+    if (_osfile(fd) & FTEXT) {
+	return _write(fd, buf, size);
+    }
+
     MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock)));
 
     if (!size || _osfile(fd) & FEOFLAG) {
Index: mvm/parse.y
===================================================================
--- mvm/parse.y	(revision 18951)
+++ mvm/parse.y	(revision 18952)
@@ -173,6 +173,15 @@
     }
     return 0;
 }
+
+
+typedef struct token_info {
+    const char *token;
+    int linenum;
+    int column;
+    int nonspc;
+    struct token_info *next;
+} token_info;
 #endif
 
 /*
@@ -235,6 +244,8 @@
     VALUE debug_lines;
     VALUE coverage;
     int nerr;
+
+    token_info *parser_token_info;
 #else
     /* Ripper only */
     VALUE parser_ruby_sourcefile_string;
@@ -575,6 +586,10 @@
 #endif
 #endif
 
+#ifndef RIPPER
+static void token_info_push(struct parser_params*, const char *token);
+static void token_info_pop(struct parser_params*, const char *token);
+#endif
 %}
 
 %pure_parser
@@ -2491,7 +2506,7 @@
 			$$ = method_arg(dispatch1(fcall, $1), arg_new());
 		    %*/
 		    }
-		| keyword_begin
+		| k_begin
 		    {
 		    /*%%%*/
 			$<num>$ = ruby_sourceline;
@@ -2499,7 +2514,7 @@
 		    %*/
 		    }
 		  bodystmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			if ($3 == NULL) {
@@ -2655,10 +2670,10 @@
 		    {
 			$$ = $2;
 		    }
-		| keyword_if expr_value then
+		| k_if expr_value then
 		  compstmt
 		  if_tail
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_IF(cond($2), $4, $5);
@@ -2667,10 +2682,10 @@
 			$$ = dispatch3(if, $2, $4, escape_Qundef($5));
 		    %*/
 		    }
-		| keyword_unless expr_value then
+		| k_unless expr_value then
 		  compstmt
 		  opt_else
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_UNLESS(cond($2), $4, $5);
@@ -2679,9 +2694,9 @@
 			$$ = dispatch3(unless, $2, $4, escape_Qundef($5));
 		    %*/
 		    }
-		| keyword_while {COND_PUSH(1);} expr_value do {COND_POP();}
+		| k_while {COND_PUSH(1);} expr_value do {COND_POP();}
 		  compstmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_WHILE(cond($3), $6, 1);
@@ -2690,9 +2705,9 @@
 			$$ = dispatch2(while, $3, $6);
 		    %*/
 		    }
-		| keyword_until {COND_PUSH(1);} expr_value do {COND_POP();}
+		| k_until {COND_PUSH(1);} expr_value do {COND_POP();}
 		  compstmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_UNTIL(cond($3), $6, 1);
@@ -2701,9 +2716,9 @@
 			$$ = dispatch2(until, $3, $6);
 		    %*/
 		    }
-		| keyword_case expr_value opt_terms
+		| k_case expr_value opt_terms
 		  case_body
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_CASE($2, $4);
@@ -2712,7 +2727,7 @@
 			$$ = dispatch2(case, $2, $4);
 		    %*/
 		    }
-		| keyword_case opt_terms case_body keyword_end
+		| k_case opt_terms case_body k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_CASE(0, $3);
@@ -2720,12 +2735,12 @@
 			$$ = dispatch2(case, Qnil, $3);
 		    %*/
 		    }
-		| keyword_for for_var keyword_in
+		| k_for for_var keyword_in
 		  {COND_PUSH(1);}
 		  expr_value do
 		  {COND_POP();}
 		  compstmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			/*
@@ -2775,7 +2790,7 @@
 			$$ = dispatch3(for, $2, $5, $8);
 		    %*/
 		    }
-		| keyword_class cpath superclass
+		| k_class cpath superclass
 		    {
 			if (in_def || in_single)
 			    yyerror("class definition in method body");
@@ -2786,7 +2801,7 @@
 		    %*/
 		    }
 		  bodystmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_CLASS($2, $5, $3);
@@ -2796,7 +2811,7 @@
 			$$ = dispatch3(class, $2, $3, $5);
 		    %*/
 		    }
-		| keyword_class tLSHFT expr
+		| k_class tLSHFT expr
 		    {
 		    /*%%%*/
 			$<num>$ = in_def;
@@ -2817,7 +2832,7 @@
 		    %*/
 		    }
 		  bodystmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_SCLASS($3, $7);
@@ -2831,7 +2846,7 @@
 			in_single = $<val>6;
 		    %*/
 		    }
-		| keyword_module cpath
+		| k_module cpath
 		    {
 			if (in_def || in_single)
 			    yyerror("module definition in method body");
@@ -2842,7 +2857,7 @@
 		    %*/
 		    }
 		  bodystmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			$$ = NEW_MODULE($2, $4);
@@ -2852,7 +2867,7 @@
 			$$ = dispatch2(module, $2, $4);
 		    %*/
 		    }
-		| keyword_def fname
+		| k_def fname
 		    {
 			$<id>$ = cur_mid;
 			cur_mid = $2;
@@ -2864,7 +2879,7 @@
 		    }
 		  f_arglist
 		  bodystmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			NODE *body = remove_begin($5);
@@ -2880,7 +2895,7 @@
 			cur_mid = $<id>3;
 		    %*/
 		    }
-		| keyword_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
+		| k_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
 		    {
 			in_single++;
 			lex_state = EXPR_END; /* force for args */
@@ -2891,7 +2906,7 @@
 		    }
 		  f_arglist
 		  bodystmt
-		  keyword_end
+		  k_end
 		    {
 		    /*%%%*/
 			NODE *body = remove_begin($8);
@@ -2951,6 +2966,83 @@
 		    }
 		;
 
+k_begin		: keyword_begin
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "begin");
+#endif
+		    }
+
+k_if		: keyword_if
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "if");
+#endif
+		    }
+
+k_unless	: keyword_unless
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "unless");
+#endif
+		    }
+
+k_while		: keyword_while
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "while");
+#endif
+		    }
+
+k_until		: keyword_until
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "until");
+#endif
+		    }
+
+k_case		: keyword_case
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "case");
+#endif
+		    }
+
+k_for		: keyword_for
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "for");
+#endif
+		    }
+
+k_class		: keyword_class
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "class");
+#endif
+		    }
+
+k_module	: keyword_module
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "module");
+#endif
+		    }
+
+k_def		: keyword_def
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_push(parser, "def");
+#endif
+		    }
+
+k_end		: keyword_end
+		    {
+#ifndef RIPPER
+			if (RTEST(ruby_verbose)) token_info_pop(parser, "end");  /* POP */
+#endif
+		    }
+
 then		: term
 		    /*%c%*/
 		    /*%c
@@ -4585,7 +4677,73 @@
 
 #define parser_isascii() ISASCII(*(lex_p-1))
 
+#ifndef RIPPER
 static int
+token_info_get_column(struct parser_params *parser, const char *token)
+{
+    int column = 1;
+    const char *p, *pend = lex_p - strlen(token);
+    for (p = lex_pbeg; p < pend; p++) {
+	if (*p == '\t') {
+	    column = (((column - 1) / 8) + 1) * 8;
+	}
+	column++;
+    }
+    return column;
+}
+
+static int
+token_info_has_nonspaces(struct parser_params *parser, const char *token)
+{
+    const char *p, *pend = lex_p - strlen(token);
+    for (p = lex_pbeg; p < pend; p++) {
+	if (*p != ' ' && *p != '\t') {
+	    return 1;
+	}
+    }
+    return 0;
+}
+
+static void
+token_info_push(struct parser_params *parser, const char *token)
+{
+    token_info *ptinfo = ALLOC(token_info);
+
+    ptinfo->token = token;
+    ptinfo->linenum = ruby_sourceline;
+    ptinfo->column = token_info_get_column(parser, token);
+    ptinfo->nonspc = token_info_has_nonspaces(parser, token);
+    ptinfo->next = parser->parser_token_info;
+
+    parser->parser_token_info = ptinfo;
+}
+
+static void
+token_info_pop(struct parser_params *parser, const char *token)
+{
+    int linenum;
+    token_info *ptinfo = parser->parser_token_info;
+
+    parser->parser_token_info = ptinfo->next;
+    if (token_info_get_column(parser, token) == ptinfo->column) { /* OK */
+	goto finish;
+    }
+    linenum = ruby_sourceline;
+    if (linenum == ptinfo->linenum) { /* SKIP */
+	goto finish;
+    }
+    if (token_info_has_nonspaces(parser, token) || ptinfo->nonspc) { /* SKIP */
+	goto finish;
+    }
+    rb_warning("mismatched indentations: line %d:'%s' and line %d:'%s'",
+	       ptinfo->linenum, ptinfo->token, linenum, token);
+
+  finish:
+    xfree(ptinfo);
+}
+#endif	/* RIPPER */
+
+static int
 parser_yyerror(struct parser_params *parser, const char *msg)
 {
 #ifndef RIPPER
Index: mvm/ext/dl/mkcallback.rb
===================================================================
--- mvm/ext/dl/mkcallback.rb	(revision 18951)
+++ mvm/ext/dl/mkcallback.rb	(revision 18952)
@@ -6,7 +6,7 @@
   pre = ""
   f.each{|line|
     line.chop!
-    if( line[-1] == ?\ )
+    if( line[-1] == ?\\ )
       line.chop!
       line.concat(" ")
       pre += line
@@ -135,16 +135,21 @@
 static void
 rb_dl_init_callbacks()
 {
+    VALUE tmp;
     cb_call = rb_intern("call");		       
 
-    rb_DLCdeclCallbackProcs = rb_ary_new();
-    rb_DLCdeclCallbackAddrs = rb_ary_new();
-    rb_DLStdcallCallbackProcs = rb_ary_new();
-    rb_DLStdcallCallbackAddrs = rb_ary_new();
-    rb_define_const(rb_mDL, "CdeclCallbackProcs", rb_DLCdeclCallbackProcs);
-    rb_define_const(rb_mDL, "CdeclCallbackAddrs", rb_DLCdeclCallbackAddrs);
-    rb_define_const(rb_mDL, "StdcallCallbackProcs", rb_DLStdcallCallbackProcs);
-    rb_define_const(rb_mDL, "StdcallCallbackAddrs", rb_DLStdcallCallbackAddrs);
+    tmp = rb_DLCdeclCallbackProcs = rb_ary_new();
+    rb_define_const(rb_mDL, "CdeclCallbackProcs", tmp);
+
+    tmp = rb_DLCdeclCallbackAddrs = rb_ary_new();
+    rb_define_const(rb_mDL, "CdeclCallbackAddrs", tmp);
+
+    tmp = rb_DLStdcallCallbackProcs = rb_ary_new();
+    rb_define_const(rb_mDL, "StdcallCallbackProcs", tmp);
+
+    tmp = rb_DLStdcallCallbackAddrs = rb_ary_new();
+    rb_define_const(rb_mDL, "StdcallCallbackAddrs", tmp);
+
 #{
     (0...MAX_DLTYPE).collect{|ty|
       sprintf("    rb_ary_push(rb_DLCdeclCallbackProcs, rb_ary_new3(%d,%s));",
Index: mvm/ext/openssl/ossl_config.c
===================================================================
--- mvm/ext/openssl/ossl_config.c	(revision 18951)
+++ mvm/ext/openssl/ossl_config.c	(revision 18952)
@@ -443,8 +443,10 @@
     eConfigError = rb_define_class_under(mOSSL, "ConfigError", eOSSLError);
     cConfig = rb_define_class_under(mOSSL, "Config", rb_cObject);
 
+    const char *default_config_file = CONF_get1_default_config_file();
     rb_define_const(cConfig, "DEFAULT_CONFIG_FILE",
-		    rb_str_new2(CONF_get1_default_config_file()));
+		    rb_str_new2(default_config_file));
+    OPENSSL_free(default_config_file);
     rb_include_module(cConfig, rb_mEnumerable);
     rb_define_singleton_method(cConfig, "parse", ossl_config_s_parse, 1);
     rb_define_alias(CLASS_OF(cConfig), "load", "new");
Index: mvm/ext/openssl/ossl_x509ext.c
===================================================================
--- mvm/ext/openssl/ossl_x509ext.c	(revision 18951)
+++ mvm/ext/openssl/ossl_x509ext.c	(revision 18952)
@@ -275,14 +275,16 @@
 {
     VALUE oid, value, critical;
     const unsigned char *p;
-    X509_EXTENSION *ext, *x = DATA_PTR(self);
+    X509_EXTENSION *ext, *x;
 
     GetX509Ext(self, ext);
     if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){
 	oid = ossl_to_der_if_possible(oid);
 	StringValue(oid);
 	p = (unsigned char *)RSTRING_PTR(oid);
-	if(!d2i_X509_EXTENSION(&x, &p, RSTRING_LEN(oid)) && (DATA_PTR(self) = x, 1))
+	x = d2i_X509_EXTENSION(&ext, &p, RSTRING_LEN(oid));
+	DATA_PTR(self) = ext;
+	if(!x)
 	    ossl_raise(eX509ExtError, NULL);
 	return self;
     }
@@ -331,6 +333,7 @@
 	ASN1_OCTET_STRING_free(asn1s);
 	ossl_raise(eX509ExtError, NULL);
     }
+    free(s);
     GetX509Ext(self, ext);
     X509_EXTENSION_set_data(ext, asn1s);
 
Index: mvm/ext/strscan/strscan.c
===================================================================
--- mvm/ext/strscan/strscan.c	(revision 18951)
+++ mvm/ext/strscan/strscan.c	(revision 18952)
@@ -407,6 +407,7 @@
     struct strscanner *p;
     regex_t *re;
     int ret;
+    int tmpreg;
 
     Check_Type(regex, T_REGEXP);
     GET_SCANNER(self, p);
@@ -416,6 +417,9 @@
         return Qnil;
     }
     re = rb_reg_prepare_re(regex, p->str);
+    tmpreg = re != RREGEXP(regex)->ptr;
+    if (!tmpreg) RREGEXP(regex)->usecnt++;
+
     if (headonly) {
         ret = onig_match(re, (UChar* )CURPTR(p),
                          (UChar* )(CURPTR(p) + S_RESTLEN(p)),
@@ -427,6 +431,16 @@
                           (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
                           &(p->regs), ONIG_OPTION_NONE);
     }
+    if (!tmpreg) RREGEXP(re)->usecnt--;
+    if (tmpreg) {
+        if (RREGEXP(regex)->usecnt) {
+            onig_free(re);
+        }
+        else {
+            onig_free(RREGEXP(regex)->ptr);
+            RREGEXP(regex)->ptr = re;
+        }
+    }
 
     if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
     if (ret < 0) {
Index: mvm/.merged-trunk-revision
===================================================================
--- mvm/.merged-trunk-revision	(revision 18951)
+++ mvm/.merged-trunk-revision	(revision 18952)
@@ -1 +1 @@
-18938
+18951

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]