* parse.y: use ASCII encoding for string literals that are
7-bit clean, fixing regression from my previous patch git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
16262b6972
commit
03919fd210
@ -1,3 +1,8 @@
|
|||||||
|
Sat Nov 10 14:43:30 2007 David Flanagan <davidflanagan@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y: use ASCII encoding for string literals that are
|
||||||
|
7-bit clean, fixing regression from my previous patch
|
||||||
|
|
||||||
Sat Nov 10 13:18:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Nov 10 13:18:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* {bcc32,win32}/Makefile.sub: vendor_ruby support.
|
* {bcc32,win32}/Makefile.sub: vendor_ruby support.
|
||||||
|
14
parse.y
14
parse.y
@ -4842,9 +4842,23 @@ parser_str_new(const char *p, long n, rb_encoding *enc, int coderange)
|
|||||||
static VALUE
|
static VALUE
|
||||||
parser_str_new2(const char *p, long n, rb_encoding *enc, int has8bit,int hasmb)
|
parser_str_new2(const char *p, long n, rb_encoding *enc, int has8bit,int hasmb)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Set coderange bit flags based on the presence of 8-bit and
|
||||||
|
* multi-byte characters in the string
|
||||||
|
*/
|
||||||
int coderange = ENC_CODERANGE_SINGLE;
|
int coderange = ENC_CODERANGE_SINGLE;
|
||||||
if (hasmb) coderange = ENC_CODERANGE_MULTI;
|
if (hasmb) coderange = ENC_CODERANGE_MULTI;
|
||||||
else if (has8bit) coderange = ENC_CODERANGE_UNKNOWN;
|
else if (has8bit) coderange = ENC_CODERANGE_UNKNOWN;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If it is all single byte characters with the 8th bit clear,
|
||||||
|
* and if the specified encoding is ASCII-compatible, then this
|
||||||
|
* string is in the ASCII subset, and we just use the ASCII encoding
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
if ((coderange == ENC_CODERANGE_SINGLE) && rb_enc_asciicompat(enc))
|
||||||
|
enc = rb_enc_default();
|
||||||
|
|
||||||
return parser_str_new(p, n, enc, coderange);
|
return parser_str_new(p, n, enc, coderange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user