Author: richter Date: Fri Jan 11 20:27:37 2013 New Revision: 1432267 URL: http://svn.apache.org/viewvc?rev=1432267&view=rev Log: Support for utf8 source code
Added: perl/embperl/trunk/test/html/utf8/ perl/embperl/trunk/test/html/utf8/epoutf8base.htm perl/embperl/trunk/test/html/utf8/epoutf8inc.htm perl/embperl/trunk/test/html/utf8/epoutf8main.pl Modified: perl/embperl/trunk/Changes.pod perl/embperl/trunk/Embperl.pm perl/embperl/trunk/Embperl/Syntax/EmbperlBlocks.pm perl/embperl/trunk/MANIFEST perl/embperl/trunk/epcomp.c perl/embperl/trunk/epeval.c Modified: perl/embperl/trunk/Changes.pod URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Changes.pod?rev=1432267&r1=1432266&r2=1432267&view=diff ============================================================================== --- perl/embperl/trunk/Changes.pod (original) +++ perl/embperl/trunk/Changes.pod Fri Jan 11 20:27:37 2013 @@ -40,6 +40,8 @@ - Log Errors form Embperl::Syntax::Mail to error log - Fix compile problem on non intel plattforms due to missing -m32 flag. + - Added support for utf8 sourcefiles. By setting + input_charset => 'utf8' =head 2.4.0 4. Oct 2010 Modified: perl/embperl/trunk/Embperl.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl.pm?rev=1432267&r1=1432266&r2=1432267&view=diff ============================================================================== --- perl/embperl/trunk/Embperl.pm (original) +++ perl/embperl/trunk/Embperl.pm Fri Jan 11 20:27:37 2013 @@ -50,7 +50,7 @@ use vars qw( @ISA = qw(Exporter DynaLoader); -$VERSION = '2.5.0_3' ; +$VERSION = '2.5.0_4' ; if ($modperl = $ENV{MOD_PERL}) Modified: perl/embperl/trunk/Embperl/Syntax/EmbperlBlocks.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Syntax/EmbperlBlocks.pm?rev=1432267&r1=1432266&r2=1432267&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Syntax/EmbperlBlocks.pm (original) +++ perl/embperl/trunk/Embperl/Syntax/EmbperlBlocks.pm Fri Jan 11 20:27:37 2013 @@ -58,7 +58,7 @@ sub new Init ($self, ref $exchange?$exchange:undef) ; - $self -> AddInitCode ('use Data::Dumper ;') ; + $self -> AddInitCode ('use Data::Dumper;') ; } return $self ; Modified: perl/embperl/trunk/MANIFEST URL: http://svn.apache.org/viewvc/perl/embperl/trunk/MANIFEST?rev=1432267&r1=1432266&r2=1432267&view=diff ============================================================================== --- perl/embperl/trunk/MANIFEST (original) +++ perl/embperl/trunk/MANIFEST Fri Jan 11 20:27:37 2013 @@ -628,6 +628,9 @@ test/html/taint.htm test/html/topinc.htm test/html/unclosed.htm test/html/upload.htm +test/html/utf8/epoutf8base.htm +test/html/utf8/epoutf8inc.htm +test/html/utf8/epoutf8main.pl test/html/var.htm test/html/varepvar.htm test/html/varerr.htm Modified: perl/embperl/trunk/epcomp.c URL: http://svn.apache.org/viewvc/perl/embperl/trunk/epcomp.c?rev=1432267&r1=1432266&r2=1432267&view=diff ============================================================================== --- perl/embperl/trunk/epcomp.c (original) +++ perl/embperl/trunk/epcomp.c Fri Jan 11 20:27:37 2013 @@ -950,8 +950,12 @@ static int embperl_CompileCmd (/*in*/ t SV * args[4] ; int nCodeLen = 0 ; int found = 0 ; + char *use_utf8 = "" ; - r -> Component.pCodeSV = NULL ; + if (strcmp (r -> Component.Config.sInputCharset, "utf8") == 0) + use_utf8 = "use utf8;" ; + + r -> Component.pCodeSV = NULL ; Ndx2StringLen (pDomTree -> xFilename, sSourcefile, nSourcefile) ; @@ -1026,8 +1030,8 @@ static int embperl_CompileCmd (/*in*/ t } } - pSV = newSVpvf("package %s ;\n#line %d \"%s\"\n%*.*s", - r -> Component.sEvalPackage, pNode -> nLinenumber, sSourcefile, l,l, pCTCode) ; + pSV = newSVpvf("package %s ; %s\n#line %d \"%s\"\n%*.*s", + r -> Component.sEvalPackage, use_utf8, pNode -> nLinenumber, sSourcefile, l,l, pCTCode) ; newSVpvf2(pSV) ; args[0] = r -> _perlsv ; if (pCode) @@ -1224,6 +1228,10 @@ static int embperl_CompileCmdEnd (/*in*/ char * pCTCode = NULL ; SV * args[4] ; STRLEN nCodeLen = 0 ; + char *use_utf8 = "" ; + + if (strcmp (r -> Component.Config.sInputCharset, "utf8") == 0) + use_utf8 = "use utf8;" ; if (pCmd -> nNodeType != pNode -> nType) @@ -1267,8 +1275,8 @@ static int embperl_CompileCmdEnd (/*in*/ } - pSV = newSVpvf("package %s ;\n#line %d \"%s\"\n%*.*s", - r -> Component.sEvalPackage, pNode -> nLinenumber, sSourcefile, l,l, pCTCode) ; + pSV = newSVpvf("package %s ; %s\n#line %d \"%s\"\n%*.*s", + r -> Component.sEvalPackage, use_utf8, pNode -> nLinenumber, sSourcefile, l,l, pCTCode) ; newSVpvf2(pSV) ; args[0] = r -> _perlsv ; if (pCode) @@ -1629,6 +1637,10 @@ int embperl_Compile (/*i nStep = 4096 ; */ int nStep = 8192 ; + char *use_utf8 = "" ; + + if (strcmp (r -> Component.Config.sInputCharset, "utf8") == 0) + use_utf8 = "use utf8;" ; if (r -> Component.Config.bDebug & dbgCompile) lprintf (r -> pApp, "[%d]EPCOMP: Start compiling %s DomTree = %d\n", r -> pThread -> nPid, sSourcefile, xDomTree) ; @@ -1694,7 +1706,7 @@ int embperl_Compile (/*i if (l > 1) { - pSV = newSVpvf("package %s ; \n%*.*s", r -> Component.sEvalPackage, l,l, r -> Component.pProgDef) ; + pSV = newSVpvf("package %s ; %s\n%*.*s", r -> Component.sEvalPackage, use_utf8, l,l, r -> Component.pProgDef) ; newSVpvf2(pSV) ; args[0] = r -> _perlsv ; args[1] = pDomTree -> pDomTreeSV ; Modified: perl/embperl/trunk/epeval.c URL: http://svn.apache.org/viewvc/perl/embperl/trunk/epeval.c?rev=1432267&r1=1432266&r2=1432267&view=diff ============================================================================== --- perl/embperl/trunk/epeval.c (original) +++ perl/embperl/trunk/epeval.c Fri Jan 11 20:27:37 2013 @@ -337,14 +337,15 @@ static int EvalAll (/*i/o*/ register req /*out*/ SV ** pRet) { epTHX_ /* dTHXsem */ - static char sFormat [] = "package %s ; sub %s { \n#line %d \"%s\"\n%s\n} %s%s" ; - static char sFormatStrict [] = "package %s ; use strict ; sub %s {\n#line %d \"%s\"\n%s\n} %s%s" ; - static char sFormatArray [] = "package %s ; sub %s { \n#line %d \"%s\"\n[%s]\n} %s%s" ; - static char sFormatStrictArray [] = "package %s ; use strict ; sub %s {\n#line %d \"%s\"\n[%s]\n} %s%s" ; + static char sFormat [] = "package %s ; %s sub %s { \n#line %d \"%s\"\n%s\n} %s%s" ; + static char sFormatStrict [] = "package %s ; %s use strict ; sub %s {\n#line %d \"%s\"\n%s\n} %s%s" ; + static char sFormatArray [] = "package %s ; %s sub %s { \n#line %d \"%s\"\n[%s]\n} %s%s" ; + static char sFormatStrictArray [] = "package %s ; %s use strict ; sub %s {\n#line %d \"%s\"\n[%s]\n} %s%s" ; SV * pSVCmd ; SV * pSVErr ; int n ; char * sRef = "" ; + char * use_utf8 = "" ; dSP; @@ -363,16 +364,19 @@ static int EvalAll (/*i/o*/ register req if (*sName) sRef = "; \\&" ; + if (strcmp (r -> Component.Config.sInputCharset, "utf8") == 0) + use_utf8 = "use utf8;" ; + if (r -> Component.bStrict) if ((flags & G_ARRAY) != G_SCALAR) - pSVCmd = newSVpvf(sFormatStrictArray, r -> Component.sEvalPackage, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; + pSVCmd = newSVpvf(sFormatStrictArray, r -> Component.sEvalPackage, use_utf8, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; else - pSVCmd = newSVpvf(sFormatStrict, r -> Component.sEvalPackage, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; + pSVCmd = newSVpvf(sFormatStrict, r -> Component.sEvalPackage, use_utf8, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; else if ((flags & G_ARRAY) != G_SCALAR) - pSVCmd = newSVpvf(sFormatArray, r -> Component.sEvalPackage, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; + pSVCmd = newSVpvf(sFormatArray, r -> Component.sEvalPackage, use_utf8, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; else - pSVCmd = newSVpvf(sFormat, r -> Component.sEvalPackage, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; + pSVCmd = newSVpvf(sFormat, r -> Component.sEvalPackage, use_utf8, sName, r -> Component.nSourceline, r -> Component.sSourcefile, sArg, sRef, sName) ; newSVpvf2(pSVCmd) ; PUSHMARK(sp); Added: perl/embperl/trunk/test/html/utf8/epoutf8base.htm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/test/html/utf8/epoutf8base.htm?rev=1432267&view=auto ============================================================================== --- perl/embperl/trunk/test/html/utf8/epoutf8base.htm (added) +++ perl/embperl/trunk/test/html/utf8/epoutf8base.htm Fri Jan 11 20:27:37 2013 @@ -0,0 +1,5 @@ + +$param[0] in obj_base = [+ $param[0] +] +$param[1] in obj_base = [+ $param[1] +] +[- Execute('*') -] + Added: perl/embperl/trunk/test/html/utf8/epoutf8inc.htm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/test/html/utf8/epoutf8inc.htm?rev=1432267&view=auto ============================================================================== --- perl/embperl/trunk/test/html/utf8/epoutf8inc.htm (added) +++ perl/embperl/trunk/test/html/utf8/epoutf8inc.htm Fri Jan 11 20:27:37 2013 @@ -0,0 +1,16 @@ + +[! $i = 'ÐÑо ÑÑÑÑкий ÑекÑÑ Ð² пеÑеменной'; $leni = length($i); !] + +<html> +<head> +<title>ÐÑовеÑка ÑÑÑÑого</title> +</head> +<body> + +TEST ([+$Embperl::VERSION+]) i: ÐÑовеÑка вÑвода пеÑеменной: [+$i+] ([+$leni+]) +1: [- $a = 'ÐÑо ÑÑÑÑкий ÑекÑÑ Ð² пеÑеменной'; $len = length($a); -] +2: ÐÑовеÑка вÑвода пеÑеменной: [+$a+] ([+$len+]) +3: $param[0] in epout8inc = [+ $param[0] +] +4: $param[1] in epout8inc = [+ $param[1] +] +</body> +</html> \ No newline at end of file Added: perl/embperl/trunk/test/html/utf8/epoutf8main.pl URL: http://svn.apache.org/viewvc/perl/embperl/trunk/test/html/utf8/epoutf8main.pl?rev=1432267&view=auto ============================================================================== --- perl/embperl/trunk/test/html/utf8/epoutf8main.pl (added) +++ perl/embperl/trunk/test/html/utf8/epoutf8main.pl Fri Jan 11 20:27:37 2013 @@ -0,0 +1,34 @@ + +use utf8 ; +use Embperl::Object ; +use FindBin ; +use Data::Dumper ; + +my $a = 'ÐÑо ÑÑÑÑкий ÑекÑÑ Ð² пеÑеменной'; +my $len = length($a) ; + +print "a:<$a>\nlen: $len\n" ; + +my $tmp = { + inputfile => $FindBin::Bin . '/epoutf8inc.htm', + object_base => 'epoutf8base.htm', + object_stopdir => $FindBin::Bin, + output => \$out, + appname => 'Test1', + param => [ 'паÑамеÑÑ', 'param2' ], + input_charset => 'utf8', + debug => 0x7fffffff, + } ; + +print "Exeecute ", Dumper ($tmp) ; + +Embperl::Object::Execute($tmp); + +print "After Embperl: utf8: ", utf8::is_utf8($out)?'yes':'no' ; + +print "Output:\n" ; +print $out, "\n" ; +print "----------------------------\n" ; + + + --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-cvs-unsubscr...@perl.apache.org For additional commands, e-mail: embperl-cvs-h...@perl.apache.org