[#12372] Release compatibility/train — Prashant Srinivasan <Prashant.Srinivasan@...>

Hello all,

28 messages 2007/10/03
[#12373] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12374] Re: Release compatibility/train — David Flanagan <david@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12376] Re: Release compatibility/train — Prashant Srinivasan <Prashant.Srinivasan@...> 2007/10/03

[#12377] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12382] Re: Release compatibility/train — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12385] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12388] Re: Release compatibility/train — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12389] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12406] Re: Release compatibility/train — "David A. Black" <dblack@...> 2007/10/03

Hi --

[#12383] Include Rake in Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

20 messages 2007/10/03

[#12539] Ordered Hashes in 1.9? — Michael Neumann <mneumann@...>

Hi all,

17 messages 2007/10/08
[#12542] Re: Ordered Hashes in 1.9? — Yukihiro Matsumoto <matz@...> 2007/10/08

Hi,

[#12681] Unicode: Progress? — murphy <murphy@...>

Hello!

17 messages 2007/10/15

[#12693] retry: revised 1.9 http patch — Hugh Sasse <hgs@...>

I'm reposting this because I've had little response to this version

11 messages 2007/10/15

[#12697] Range.first is incompatible with Enumerable.first — David Flanagan <david@...>

The new Enumerable.first method is a generalization of Array.first to

11 messages 2007/10/16

[#12754] Improving 'syntax error, unexpected $end, expecting kEND'? — Hugh Sasse <hgs@...>

I've had a look at this, but can't see how to do it: When I get

17 messages 2007/10/18
[#12886] Re: Improving 'syntax error, unexpected $end, expecting kEND'? — David Flanagan <david@...> 2007/10/23

The patch below changes this message to:

[#12758] Encoding::primary_encoding — David Flanagan <david@...>

Hi,

25 messages 2007/10/18
[#12763] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/19

Hi,

[#12802] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/21

Nobuyoshi Nakada schrieb:

[#12803] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/21

Hi,

[#12804] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/21

Nobuyoshi Nakada schrieb:

[#12808] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/22

Hi,

[#12818] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/22

Nobuyoshi Nakada schrieb:

[#12820] Re: Encoding::primary_encoding — "Michal Suchanek" <hramrach@...> 2007/10/22

T24gMjIvMTAvMjAwNywgV29sZmdhbmcgTsOhZGFzaS1Eb25uZXIgPGVkLm9kYW5vd0B3b25hZG8u

[#12823] Re: Encoding::primary_encoding — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/22

Michal Suchanek schrieb:

[#12824] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/22

Hi,

[#12767] \u escapes in string literals: proof of concept implementation — David Flanagan <david@...>

Back at the end of August, Matz wrote (see

45 messages 2007/10/19
[#12769] Re: \u escapes in string literals: proof of concept implementation — "Nobuyoshi Nakada" <nobu@...> 2007/10/19

Hi,

[#12782] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/20

Nobuyoshi Nakada wrote:

[#12831] Re: \u escapes in string literals: proof of concept implementation — Yukihiro Matsumoto <matz@...> 2007/10/22

Hi,

[#12841] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/22

Yukihiro Matsumoto wrote:

[#12862] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/23

At 04:19 07/10/23, David Flanagan wrote:

[#12864] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/23

Martin Duerst wrote:

[#12870] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/23

At 13:10 07/10/23, David Flanagan wrote:

[#12872] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/23

Martin Duerst wrote:

[#12936] Re: \u escapes in string literals: proof of concept implementation — Yukihiro Matsumoto <matz@...> 2007/10/25

Hi,

[#12980] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/26

Yukihiro Matsumoto wrote:

[#13028] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/10/29

Hi,

[#13032] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/29

Nobuyoshi Nakada wrote:

[#13034] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/10/29

Hi,

[#13082] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/30

At 16:46 07/10/29, Nobuyoshi Nakada wrote:

[#13231] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/11/06

Hi,

[#13234] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/11/06

At 11:29 07/11/06, Nobuyoshi Nakada wrote:

[#12825] clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...>

Hi,

53 messages 2007/10/22
[#12830] Re: clarification of ruby libraries installation paths? — Ben Bleything <ben@...> 2007/10/22

On Mon, Oct 22, 2007, Lucas Nussbaum wrote:

[#12833] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/22

On 23/10/07 at 00:13 +0900, Ben Bleything wrote:

[#12835] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/22

On 10/22/07, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#12836] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/22

On 23/10/07 at 01:55 +0900, Austin Ziegler wrote:

[#12888] Re: clarification of ruby libraries installation paths? — Gonzalo Garramu <ggarra@...> 2007/10/23

Lucas Nussbaum wrote:

[#12894] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/24

On 24/10/07 at 05:14 +0900, Gonzalo Garramu wrote:

[#13057] Re: clarification of ruby libraries installation paths? — Gonzalo Garramu <ggarra@...> 2007/10/29

Lucas Nussbaum wrote:

[#13058] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/29

On 30/10/07 at 07:28 +0900, Gonzalo Garramu wrote:

[#12848] Re: clarification of ruby libraries installation paths? — Sam Roberts <sroberts@...> 2007/10/22

On Tue, Oct 23, 2007 at 01:55:29AM +0900, Austin Ziegler wrote:

[#12855] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/23

On 10/22/07, Sam Roberts <sroberts@uniserve.com> wrote:

[#13016] Re: clarification of ruby libraries installation paths? — bob@... (Bob Proulx) 2007/10/28

Austin Ziegler wrote:

[#13029] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/29

On 10/28/07, Bob Proulx <bob@proulx.com> wrote:

[#13054] Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — Lucas Nussbaum <lucas@...> 2007/10/29

Austin,

[#13055] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/29

On 10/29/07, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#13064] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Austin Ziegler" <halostatue@...> 2007/10/30

On 10/29/07, Luis Lavena <luislavena@gmail.com> wrote:

[#13066] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/30

On 10/30/07, Austin Ziegler <halostatue@gmail.com> wrote:

[#13094] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Rick Bradley" <rick@...> 2007/10/30

Do we think that maybe, just maybe, things went off the rails when the

[#13095] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/30

On 10/30/07, Rick Bradley <rick@rickbradley.com> wrote:

[#12900] Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...>

Dear Ruby 1.9 architects, developers, and testers!

31 messages 2007/10/24
[#12905] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Yukihiro Matsumoto <matz@...> 2007/10/24

Hi,

[#12907] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/24

Yukihiro Matsumoto schrieb:

[#12909] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Yukihiro Matsumoto <matz@...> 2007/10/24

Hi,

[#12940] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/25
[#12942] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/25

I have a (hopefully) final question before testing all

[#12948] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Nobuyoshi Nakada <nobu@...> 2007/10/26

Hi,

[#12951] Fluent programming in Ruby — David Flanagan <david@...>

From the ChangeLog:

16 messages 2007/10/26

[#12996] General hash keys for colon notation — murphy <murphy@...>

Dear language designer(s) and parser wizards,

16 messages 2007/10/28

[#13027] Implementation of "guessUTF" method - final questions — Wolfgang Nádasi-Donner <ed.odanow@...>

Dear Ruby designers, developers, and testers!

22 messages 2007/10/29

[#13069] new Enumerable.butfirst method — David Flanagan <david@...>

Matz,

17 messages 2007/10/30

file encoding comments and a patch to parse.y

From: David Flanagan <david@...>
Date: 2007-10-12 19:52:37 UTC
List: ruby-core #12629
Matz, Nobu:

I've just looked over your recent patches to parse.y for file encoding 
comments.  set_file_encoding is a nice piece of work!  What a sweet 
switch statement :-)

I notice, however, that you use strncasecmp in one part of the function 
but only check for lowercase letters in the switch.  This results in the 
strange behavior where this comment sets the encoding to UTF-8

     #CODING: utf-8

But this comment, with just one extra space, does not:

     # CODING: utf-8

The attached file "patch1" is a simple patch that fixes this problem.

The attached "patch2" is a larger patch that deletes all of the 
magic_comment code in the file because the new set_file_encoding 
function is general enough that it is no longer needed.  I'm in over my 
head here and this may be a completely inappropriate patch, especially 
since it deletes some ifdef RIPPER stuff.  But while I was making an 
aggressive patch like this, I took the liberty of changing the method 
name set_file_encoding to set_encoding_from_comment.

I hope these are helpful.

	David

Attachments (2)

patch1 (741 Bytes, text/x-diff)
Index: parse.y
===================================================================
--- parse.y	(revision 13687)
+++ parse.y	(working copy)
@@ -5693,12 +5693,12 @@
     for (;;) {
 	if (send - str <= 6) return;
 	switch (str[6]) {
-	  case 'c': str += 6; continue;
-	  case 'o': str += 5; continue;
-	  case 'd': str += 4; continue;
-	  case 'i': str += 3; continue;
-	  case 'n': str += 2; continue;
-	  case 'g': str += 1; continue;
+	case 'C': case 'c': str += 6; continue;
+	case 'O': case 'o': str += 5; continue;
+	case 'D': case 'd': str += 4; continue;
+	case 'I': case 'i': str += 3; continue;
+	case 'N': case 'n': str += 2; continue;
+	case 'G': case 'g': str += 1; continue;
 	  case '=': case ':':
 	    sep = 1;
 	    str += 6;
patch2 (4.85 KB, text/x-diff)
Index: parse.y
===================================================================
--- parse.y	(revision 13687)
+++ parse.y	(working copy)
@@ -5534,7 +5534,6 @@
 #endif
 }
 
-/* emacsen -*- hack */
 static void
 parser_set_encode(struct parser_params *parser, const char *name)
 {
@@ -5545,147 +5544,10 @@
     parser->enc = rb_enc_from_index(idx);
 }
 
-#ifndef RIPPER
-typedef void (*rb_magic_comment_setter_t)(struct parser_params *parser, const char *name, const char *val);
-
 static void
-magic_comment_encoding(struct parser_params *parser, const char *name, const char *val)
+set_encoding_from_comment(struct parser_params *parser,
+			  const char *str, const char *send)
 {
-    if (parser && parser->line_count != (parser->has_shebang ? 2 : 1))
-	return;
-    parser_set_encode(parser, val);
-}
-
-struct magic_comment {
-    const char *name;
-    rb_magic_comment_setter_t func;
-};
-
-static const struct magic_comment magic_comments[] = {
-    {"coding", magic_comment_encoding},
-    {"encoding", magic_comment_encoding},
-};
-#endif
-
-static const char *
-magic_comment_marker(const char *str, int len)
-{
-    int i = 2;
-
-    while (i < len) {
-	switch (str[i]) {
-	  case '-':
-	    if (str[i-1] == '*' && str[i-2] == '-') {
-		return str + i + 1;
-	    }
-	    i += 2;
-	    break;
-	  case '*':
-	    if (i + 1 >= len) return 0;
-	    if (str[i+1] != '-') {
-		i += 4;
-	    }
-	    else if (str[i-1] != '-') {
-		i += 2;
-	    }
-	    else {
-		return str + i + 2;
-	    }
-	    break;
-	  default:
-	    i += 3;
-	    break;
-	}
-    }
-    return 0;
-}
-
-static int
-parser_magic_comment(struct parser_params *parser, const char *str, int len)
-{
-    VALUE name = 0, val = 0;
-    const char *beg, *end, *vbeg, *vend;
-#define str_copy(_s, _p, _n) ((_s) \
-	? (rb_str_resize((_s), (_n)), \
-	   MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
-	: ((_s) = STR_NEW((_p), (_n))))
-
-    if (len <= 7) return Qfalse;
-    if (!(beg = magic_comment_marker(str, len))) return Qfalse;
-    if (!(end = magic_comment_marker(beg, str + len - beg))) return Qfalse;
-    str = beg;
-    len = end - beg - 3;
-
-    /* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
-    while (len > 0) {
-#ifndef RIPPER
-	const struct magic_comment *p = magic_comments;
-#endif
-	int n = 0;
-
-	for (; len > 0 && *str; str++, --len) {
-	    switch (*str) {
-	      case '\'': case '"': case ':': case ';':
-		continue;
-	    }
-	    if (!ISSPACE(*str)) break;
-	}
-	for (beg = str; len > 0; str++, --len) {
-	    switch (*str) {
-	      case '\'': case '"': case ':': case ';':
-		break;
-	      default:
-		if (ISSPACE(*str)) break;
-		continue;
-	    }
-	    break;
-	}
-	for (end = str; len > 0 && ISSPACE(*str); str++, --len);
-	if (!len) break;
-	if (*str != ':') continue;
-
-	do str++; while (--len > 0 && ISSPACE(*str));
-	if (!len) break;
-	if (*str == '"') {
-	    for (vbeg = ++str; --len > 0 && *str != '"'; str++) {
-		if (*str == '\\') {
-		    --len;
-		    ++str;
-		}
-	    }
-	    vend = str;
-	    if (len) {
-		--len;
-		++str;
-	    }
-	}
-	else {
-	    for (vbeg = str; len > 0 && *str != '"' && !ISSPACE(*str); --len, str++);
-	    vend = str;
-	}
-	while (len > 0 && (*str == ';' || ISSPACE(*str))) --len, str++;
-
-	n = end - beg;
-	str_copy(name, beg, n);
-#ifndef RIPPER
-	do {
-	    if (strncasecmp(p->name, RSTRING_PTR(name), n) == 0) {
-		str_copy(val, vbeg, vend - vbeg);
-		(*p->func)(parser, RSTRING_PTR(name), RSTRING_PTR(val));
-		break;
-	    }
-	} while (++p < magic_comments + sizeof(magic_comments) / sizeof(*p));
-#else
-	dispatch2(magic_comment, name, val);
-#endif
-    }
-
-    return Qtrue;
-}
-
-static void
-set_file_encoding(struct parser_params *parser, const char *str, const char *send)
-{
     int sep = 0;
     const char *beg = str;
     VALUE s;
@@ -5693,12 +5555,12 @@
     for (;;) {
 	if (send - str <= 6) return;
 	switch (str[6]) {
-	  case 'c': str += 6; continue;
-	  case 'o': str += 5; continue;
-	  case 'd': str += 4; continue;
-	  case 'i': str += 3; continue;
-	  case 'n': str += 2; continue;
-	  case 'g': str += 1; continue;
+	case 'C': case 'c': str += 6; continue;
+	case 'O': case 'o': str += 5; continue;
+	case 'D': case 'd': str += 4; continue;
+	case 'I': case 'i': str += 3; continue;
+	case 'N': case 'n': str += 2; continue;
+	case 'G': case 'g': str += 1; continue;
 	  case '=': case ':':
 	    sep = 1;
 	    str += 6;
@@ -5815,13 +5677,8 @@
 	goto retry;
 
       case '#':		/* it's a comment */
-	if (!parser->has_shebang || parser->line_count != 1) {
-	    /* no magic_comment in shebang line */
-	    if (!parser_magic_comment(parser, lex_p, lex_pend - lex_p)) {
-		if (parser->line_count == (parser->has_shebang ? 2 : 1)) {
-		    set_file_encoding(parser, lex_p, lex_pend);
-		}
-	    }
+	if (parser->line_count == (parser->has_shebang ? 2 : 1)) {
+	  set_encoding_from_comment(parser, lex_p, lex_pend);
 	}
 	lex_p = lex_pend;
 #ifdef RIPPER

In This Thread

Prev Next