Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50868 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10569 invoked from network); 6 Dec 2010 10:32:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2010 10:32:23 -0000 Authentication-Results: pb1.pair.com header.from=mozo@mozo.jp; sender-id=permerror Authentication-Results: pb1.pair.com smtp.mail=mozo@mozo.jp; spf=permerror; sender-id=permerror Received-SPF: error (pb1.pair.com: domain mozo.jp from 209.85.161.42 cause and error) X-PHP-List-Original-Sender: mozo@mozo.jp X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:63378] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/D1-30815-5BBBCFC4 for ; Mon, 06 Dec 2010 05:32:23 -0500 Received: by fxm11 with SMTP id 11so9634212fxm.29 for ; Mon, 06 Dec 2010 02:32:18 -0800 (PST) Received: by 10.223.85.197 with SMTP id p5mr2207034fal.65.1291631538818; Mon, 06 Dec 2010 02:32:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.78.140 with HTTP; Mon, 6 Dec 2010 02:31:58 -0800 (PST) In-Reply-To: <4CE537B0.1030607@zend.com> References: <4CE537B0.1030607@zend.com> Date: Mon, 6 Dec 2010 19:31:58 +0900 Message-ID: To: Dmitry Stogov Cc: PHP Internals , Andi Gutmans , Zeev Suraski Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: --enable-zend-multibyte From: mozo@mozo.jp (Moriyoshi Koizumi) Hi, How about using the value of mbstring.script_encoding to determine whether to enable the encoding conversion feature? If the value is the same as that of mbstring.internal_encoding, then no conversion should be needed in the first place. Besides we can define some singular value like "none" that completely disables the conversion. Regarding the dependency on mbstring extension, I think it's time to enable mbstring by default. Regards, Moriyoshi On Thu, Nov 18, 2010 at 11:26 PM, Dmitry Stogov wrote: > Hi, > > The proposed patch allows compiling PHP with --enable-zend-multibyte and > then enable or disable multibyte support at run-time using > zend.multibyte=3D0/1 in php.ini. As result the single binary will be able= to > support multibyte encodings and run without zend-multibyte overhead > dependent on configuration. > > The patch doesn't affect PHP compiled without --enable-zend-multibyte. > > I'm going to commit it into trunk before alpha. > Any objections? > > Thanks. Dmitry. > > Index: ext/standard/info.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- ext/standard/info.c (revision 305494) > +++ ext/standard/info.c (working copy) > @@ -760,7 +760,7 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0php_info_print_table_row(2, "Zend Memory M= anager", > is_zend_mm(TSRMLS_C) ? "enabled" : "disabled" ); > > =A0#ifdef ZEND_MULTIBYTE > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 php_info_print_table_row(2, "Zend Multibyte= Support", > "enabled"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 php_info_print_table_row(2, "Zend Multibyte= Support", > CG(multibyte) ? "enabled" : "disabled"); > =A0#else > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0php_info_print_table_row(2, "Zend Multibyt= e Support", > "disabled"); > =A0#endif > Index: ext/mbstring/mbstring.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- ext/mbstring/mbstring.c =A0 =A0 (revision 305494) > +++ ext/mbstring/mbstring.c =A0 =A0 (working copy) > @@ -1132,6 +1132,9 @@ > =A0{ > =A0 =A0 =A0 =A0int *list, size; > > + =A0 =A0 =A0 if (!CG(multibyte)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FAILURE; > + =A0 =A0 =A0 } > =A0 =A0 =A0 =A0if (php_mb_parse_encoding_list(new_value, new_value_length= , &list, > &size, 1 TSRMLS_CC)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (MBSTRG(script_encoding_list) !=3D NULL= ) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0free(MBSTRG(script_encodin= g_list)); > @@ -1442,8 +1445,10 @@ > =A0 =A0 =A0 =A0PHP_RINIT(mb_regex) (INIT_FUNC_ARGS_PASSTHRU); > =A0#endif > =A0#ifdef ZEND_MULTIBYTE > - > zend_multibyte_set_internal_encoding(mbfl_no_encoding2name(MBSTRG(interna= l_encoding)) > TSRMLS_CC); > - =A0 =A0 =A0 php_mb_set_zend_encoding(TSRMLS_C); > + =A0 =A0 =A0 if (CG(multibyte)) { > + > zend_multibyte_set_internal_encoding(mbfl_no_encoding2name(MBSTRG(interna= l_encoding)) > TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 php_mb_set_zend_encoding(TSRMLS_C); > + =A0 =A0 =A0 } > =A0#endif /* ZEND_MULTIBYTE */ > > =A0 =A0 =A0 =A0return SUCCESS; > @@ -1570,7 +1575,7 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MBSTRG(current_internal_en= coding) =3D no_encoding; > =A0#ifdef ZEND_MULTIBYTE > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* TODO: make independent = from > mbstring.encoding_translation? */ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (MBSTRG(encoding_transla= tion)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (CG(multibyte) && MBSTRG= (encoding_translation)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0zend_multi= byte_set_internal_encoding(name > TSRMLS_CC); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0#endif /* ZEND_MULTIBYTE */ > Index: Zend/zend.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/zend.c (revision 305494) > +++ Zend/zend.c (working copy) > @@ -93,6 +93,7 @@ > =A0 =A0 =A0 =A0ZEND_INI_ENTRY("error_reporting", =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NULL, > =A0 =A0 =A0 =A0 =A0 ZEND_INI_ALL, =A0 =A0 =A0 =A0 =A0 OnUpdateErrorReport= ing) > =A0 =A0 =A0 =A0STD_ZEND_INI_BOOLEAN("zend.enable_gc", =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"1", > =A0 =A0ZEND_INI_ALL, =A0 =A0 =A0 =A0 =A0 OnUpdateGCEnabled, =A0 =A0 =A0gc= _enabled, > zend_gc_globals, =A0 =A0 =A0 =A0gc_globals) > =A0#ifdef ZEND_MULTIBYTE > + =A0 =A0 =A0 STD_ZEND_INI_BOOLEAN("zend.multibyte", "0", ZEND_INI_PERDIR= , > OnUpdateBool, multibyte, =A0 =A0 =A0zend_compiler_globals, compiler_globa= ls) > =A0 =A0 =A0 =A0STD_ZEND_INI_BOOLEAN("detect_unicode", "1", ZEND_INI_ALL, > OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals) > =A0#endif > =A0ZEND_INI_END() > Index: Zend/zend_language_scanner.l > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/zend_language_scanner.l =A0 =A0 =A0 =A0(revision 305494) > +++ Zend/zend_language_scanner.l =A0 =A0 =A0 =A0(working copy) > @@ -181,7 +181,7 @@ > =A0 =A0 =A0 =A0lex_state->filename =3D zend_get_compiled_filename(TSRMLS_= C); > =A0 =A0 =A0 =A0lex_state->lineno =3D CG(zend_lineno); > > -#ifdef ZEND_MULTIBYTE > +#ifdef ZEND_MULTIBYTE > =A0 =A0 =A0 =A0lex_state->script_org =3D SCNG(script_org); > =A0 =A0 =A0 =A0lex_state->script_org_size =3D SCNG(script_org_size); > =A0 =A0 =A0 =A0lex_state->script_filtered =3D SCNG(script_filtered); > @@ -270,27 +270,32 @@ > > =A0 =A0 =A0 =A0if (size !=3D -1) { > =A0#ifdef ZEND_MULTIBYTE > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (zend_multibyte_read_script((unsigned ch= ar *)buf, size > TSRMLS_CC) !=3D 0) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FAILURE; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (CG(multibyte)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (zend_multibyte_read_scr= ipt((unsigned char *)buf, > size TSRMLS_CC) !=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FAIL= URE; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(yy_in) =3D NULL; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(yy_in) =3D NULL; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_multibyte_set_filter(NULL TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_multibyte_set_filter(N= ULL TSRMLS_CC); > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!SCNG(input_filter)) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_filtered) =3D (= unsigned > char*)emalloc(SCNG(script_org_size)+1); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 memcpy(SCNG(script_filtered= ), SCNG(script_org), > SCNG(script_org_size)+1); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_filtered_size) = =3D SCNG(script_org_size); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!SCNG(input_filter)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script= _filtered) =3D (unsigned > char*)emalloc(SCNG(script_org_size)+1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 memcpy(SCNG= (script_filtered), > SCNG(script_org), SCNG(script_org_size)+1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script= _filtered_size) =3D > SCNG(script_org_size); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(input_= filter)(&SCNG(script_filtered), > &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) > TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (SCNG(sc= ript_filtered) =3D=3D NULL) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 zend_error_noreturn(E_COMPILE_ERROR, > "Could not convert the script from the detected " > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "encoding \"%s\" to > a compatible encoding", LANG_SCNG(script_encoding)->name); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(yy_start) =3D SCNG(scr= ipt_filtered) - offset; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 yy_scan_buffer((char *)SCNG= (script_filtered), > SCNG(script_filtered_size) TSRMLS_CC); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(input_filter)(&SCNG(sc= ript_filtered), > &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) > TSRMLS_CC); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (SCNG(script_filtered) = =3D=3D NULL) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_error_= noreturn(E_COMPILE_ERROR, "Could > not convert the script from the detected " > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 "encoding \"%s\" to a > compatible encoding", LANG_SCNG(script_encoding)->name); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(yy_start) =3D buf - of= fset; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 yy_scan_buffer(buf, size TS= RMLS_CC); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(yy_start) =3D SCNG(script_filtered) - = offset; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 yy_scan_buffer((char *)SCNG(script_filtered= ), > SCNG(script_filtered_size) TSRMLS_CC); > =A0#else /* !ZEND_MULTIBYTE */ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0SCNG(yy_start) =3D buf - offset; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0yy_scan_buffer(buf, size TSRMLS_CC); > @@ -438,20 +443,24 @@ > =A0 =A0 =A0 =A0SCNG(yy_start) =3D NULL; > > =A0#ifdef ZEND_MULTIBYTE > - =A0 =A0 =A0 SCNG(script_org) =3D (unsigned char *)estrdup(str->value.st= r.val); > - =A0 =A0 =A0 SCNG(script_org_size) =3D str->value.str.len; > + =A0 =A0 =A0 if (CG(multibyte)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_org) =3D (unsigned char > *)estrdup(str->value.str.val); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_org_size) =3D str->value.str.le= n; > > - =A0 =A0 =A0 zend_multibyte_set_filter(CG(internal_encoding) TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_multibyte_set_filter(CG(internal_encod= ing) TSRMLS_CC); > > - =A0 =A0 =A0 if (!SCNG(input_filter)) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_filtered) =3D (unsigned > char*)emalloc(SCNG(script_org_size)+1); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 memcpy(SCNG(script_filtered), SCNG(script_o= rg), > SCNG(script_org_size)+1); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_filtered_size) =3D SCNG(script_= org_size); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!SCNG(input_filter)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_filtered) =3D (= unsigned > char*)emalloc(SCNG(script_org_size)+1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 memcpy(SCNG(script_filtered= ), SCNG(script_org), > SCNG(script_org_size)+1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(script_filtered_size) = =3D SCNG(script_org_size); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(input_filter)(&SCNG(sc= ript_filtered), > &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) > TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 yy_scan_buffer((char *)SCNG(script_filtered= ), > SCNG(script_filtered_size) TSRMLS_CC); > =A0 =A0 =A0 =A0} else { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCNG(input_filter)(&SCNG(script_filtered), > &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) > TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 yy_scan_buffer(str->value.str.val, str->val= ue.str.len > TSRMLS_CC); > =A0 =A0 =A0 =A0} > - > - =A0 =A0 =A0 yy_scan_buffer((char *)SCNG(script_filtered), > SCNG(script_filtered_size) TSRMLS_CC); > =A0#else /* !ZEND_MULTIBYTE */ > =A0 =A0 =A0 =A0yy_scan_buffer(str->value.str.val, str->value.str.len TSRM= LS_CC); > =A0#endif /* ZEND_MULTIBYTE */ > Index: Zend/zend_compile.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/zend_compile.c (revision 305494) > +++ Zend/zend_compile.c (working copy) > @@ -149,14 +149,12 @@ > > =A0 =A0 =A0 =A0/* NULL, name length, filename length, last accepting char= position > length */ > =A0 =A0 =A0 =A0result->value.str.len =3D 1+name_length+strlen(filename)+c= har_pos_len; > -#ifdef ZEND_MULTIBYTE > + > =A0 =A0 =A0 =A0/* must be binary safe */ > =A0 =A0 =A0 =A0result->value.str.val =3D (char *) safe_emalloc(result->va= lue.str.len, > 1, 1); > =A0 =A0 =A0 =A0result->value.str.val[0] =3D '\0'; > =A0 =A0 =A0 =A0sprintf(result->value.str.val+1, "%s%s%s", name, filename, > char_pos_buf); > -#else > - =A0 =A0 =A0 zend_spprintf(&result->value.str.val, 0, "%c%s%s%s", '\0', = name, > filename, char_pos_buf); > -#endif /* ZEND_MULTIBYTE */ > + > =A0 =A0 =A0 =A0result->type =3D IS_STRING; > =A0 =A0 =A0 =A0Z_SET_REFCOUNT_P(result, 1); > =A0} > @@ -5861,51 +5859,53 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0CG(declarables).ticks =3D val->u.constant; > =A0#ifdef ZEND_MULTIBYTE > =A0 =A0 =A0 =A0} else if (!zend_binary_strcasecmp(var->u.constant.value.s= tr.val, > var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_encoding *new_encoding, *old_encoding; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_encoding_filter old_input_filter; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (CG(multibyte)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_encoding *new_encoding= , *old_encoding; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_encoding_filter old_in= put_filter; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((Z_TYPE(val->u.constant) & IS_CONSTANT_= TYPE_MASK) =3D=3D > IS_CONSTANT) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_error(E_COMPILE_ERROR,= "Cannot use constants as > encoding"); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > - > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Check that the pragma comes before any= opcodes. If the > compilation > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* got as far as this, the previous porti= on of the script > must have been > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* parseable according to the .ini script= _encoding setting. > We still > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* want to tell them to put declare() at = the top. > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int num =3D CG(active_op_ar= ray)->last; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* ignore ZEND_EXT_STMT and= ZEND_TICKS */ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (num > 0 && > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(CG(active_o= p_array)->opcodes[num-1].opcode > =3D=3D ZEND_EXT_STMT || > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG(active_o= p_array)->opcodes[num-1].opcode > =3D=3D ZEND_TICKS)) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 --num; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((Z_TYPE(val->u.constant= ) & > IS_CONSTANT_TYPE_MASK) =3D=3D IS_CONSTANT) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_error(= E_COMPILE_ERROR, "Cannot use > constants as encoding"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (num > 0) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_error(= E_COMPILE_ERROR, "Encoding > declaration pragma must be the very first statement in the script"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Check that the pragma = comes before any opcodes. > If the compilation > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* got as far as this, th= e previous portion of the > script must have been > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* parseable according to= the .ini script_encoding > setting. We still > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* want to tell them to p= ut declare() at the top. > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int num =3D= CG(active_op_array)->last; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* ignore Z= END_EXT_STMT and ZEND_TICKS */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (num = > 0 && > + > =A0(CG(active_op_array)->opcodes[num-1].opcode =3D=3D ZEND_EXT_STMT || > + > CG(active_op_array)->opcodes[num-1].opcode =3D=3D ZEND_TICKS)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 --num; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (num > 0= ) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 zend_error(E_COMPILE_ERROR, > "Encoding declaration pragma must be the very first statement in the > script"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG(encoding_declared) =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG(encoding_declared) =3D 1= ; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 convert_to_string(&val->u.constant); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 new_encoding =3D > zend_multibyte_fetch_encoding(val->u.constant.value.str.val); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!new_encoding) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_error(E_COMPILE_WARNIN= G, "Unsupported encoding > [%s]", val->u.constant.value.str.val); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 old_input_filter =3D LANG_S= CNG(input_filter); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 old_encoding =3D LANG_SCNG(= script_encoding); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_multibyte_set_filter(n= ew_encoding TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 convert_to_string(&val->u.c= onstant); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 new_encoding =3D > zend_multibyte_fetch_encoding(val->u.constant.value.str.val); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!new_encoding) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_error(= E_COMPILE_WARNING, "Unsupported > encoding [%s]", val->u.constant.value.str.val); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 old_input_f= ilter =3D LANG_SCNG(input_filter); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 old_encodin= g =3D LANG_SCNG(script_encoding); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zend_multib= yte_set_filter(new_encoding > TSRMLS_CC); > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* need to re-scan if input= filter changed */ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (old_input_filter !=3D L= ANG_SCNG(input_filter) || > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((old_input= _filter =3D=3D > zend_multibyte_script_encoding_filter) && > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(new_enc= oding !=3D old_encoding))) { > - > zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* need to = re-scan if input filter changed > */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (old_inp= ut_filter !=3D > LANG_SCNG(input_filter) || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 ((old_input_filter =3D=3D > zend_multibyte_script_encoding_filter) && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0(new_encoding !=3D old_encoding))) { > + > zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 efree(val->u.constant.value.str.val); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 zval_dtor(&val->u.constant); > =A0#else =A0/* !ZEND_MULTIBYTE */ > =A0 =A0 =A0 =A0} else if (!zend_binary_strcasecmp(var->u.constant.value.s= tr.val, > var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Do not generate any kind of warning for= encoding declares > */ > Index: Zend/tests/multibyte/multibyte_encoding_002.phpt > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/tests/multibyte/multibyte_encoding_002.phpt =A0 =A0(revision 305= 496) > +++ Zend/tests/multibyte/multibyte_encoding_002.phpt =A0 =A0(working copy= ) > @@ -10,6 +10,7 @@ > =A0} > =A0?> > =A0--INI-- > +zend.multibyte=3D1 > =A0mbstring.internal_encoding=3Diso-8859-1 > =A0--FILE-- > =A0=EF>=BF Index: Zend/tests/multibyte/multibyte_encoding_003.phpt > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/tests/multibyte/multibyte_encoding_003.phpt =A0 =A0(revision 305= 496) > +++ Zend/tests/multibyte/multibyte_encoding_003.phpt =A0 =A0(working copy= ) > @@ -10,6 +10,7 @@ > =A0} > =A0?> > =A0--INI-- > +zend.multibyte=3D1 > =A0mbstring.internal_encoding=3Diso-8859-1 > =A0--FILE-- > =A0=FF=FE< > Index: Zend/tests/multibyte/multibyte_encoding_004.phpt > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/tests/multibyte/multibyte_encoding_004.phpt =A0 =A0(revision 305= 496) > +++ Zend/tests/multibyte/multibyte_encoding_004.phpt =A0 =A0(working copy= ) > @@ -10,6 +10,7 @@ > =A0} > =A0?> > =A0--INI-- > +zend.multibyte=3D1 > =A0mbstring.script_encoding=3DShift_JIS > =A0mbstring.internal_encoding=3DShift_JIS > =A0--FILE-- > Index: Zend/tests/multibyte/multibyte_encoding_005.phpt > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/tests/multibyte/multibyte_encoding_005.phpt =A0 =A0(revision 305= 496) > +++ Zend/tests/multibyte/multibyte_encoding_005.phpt =A0 =A0(working copy= ) > @@ -10,6 +10,7 @@ > =A0} > =A0?> > =A0--INI-- > +zend.multibyte=3D1 > =A0mbstring.encoding_translation =3D On > =A0mbstring.script_encoding=3DShift_JIS > =A0mbstring.internal_encoding=3DUTF-8 > Index: Zend/tests/multibyte/multibyte_encoding_001.phpt > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/tests/multibyte/multibyte_encoding_001.phpt =A0 =A0(revision 305= 496) > +++ Zend/tests/multibyte/multibyte_encoding_001.phpt =A0 =A0(working copy= ) > @@ -10,6 +10,7 @@ > =A0} > =A0?> > =A0--INI-- > +zend.multibyte=3D1 > =A0mbstring.internal_encoding=3DSJIS > =A0--FILE-- > =A0 Index: Zend/zend_globals.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Zend/zend_globals.h (revision 305494) > +++ Zend/zend_globals.h (working copy) > @@ -153,6 +153,7 @@ > =A0#ifdef ZEND_MULTIBYTE > =A0 =A0 =A0 =A0zend_encoding **script_encoding_list; > =A0 =A0 =A0 =A0size_t script_encoding_list_size; > + =A0 =A0 =A0 zend_bool multibyte; > =A0 =A0 =A0 =A0zend_bool detect_unicode; > =A0 =A0 =A0 =A0zend_bool encoding_declared; > > >