Changeset 13710 for src/Pugs/Run

Show
Ignore:
Timestamp:
09/28/06 06:48:03 (2 years ago)
Author:
audreyt
Message:

* Unicode support for the embedded Perl5 bridge. (This takes effect iff

the embedded Perl supports SvUTF8_on, typically Perl 5.8+.)

  • Source code in eval('...', :lang<perl5>) can now contain non-ASCII characters; they are treated as if "use utf8;" is in effect.
  • Str objects passing from Pugs land into Perl 5 are always turned into SvUTF8_on unicode strings.
  • Strings passed from Perl 5 to Pugs land are always converted into Unicode Str objects for now; this may be relaxed once we have a native Buf type in Pugs land.
  • Both named and unnamed regexes now assumes Unicode semantics.

* Use New()/Safefree() instead of malloc()/free() in p5embed APIs.

* Use svpvn and CStringLen instead of svpv and CString, so strings with

embedded nulls can be safely passed either way.

* In non-embedded builds, call binmode(STDIN, ':utf8') only on

Perl 5.7 or later.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Run/Perl5.hs

    r13658 r13710  
    4242    nvToVal :: CDouble -> IO PugsVal 
    4343 
    44 foreign export ccall "pugs_PvToVal" 
    45     pvToVal :: CString -> IO PugsVal 
     44foreign export ccall "pugs_PvnToVal" 
     45    pvnToVal :: CString -> CInt -> IO PugsVal 
    4646 
    4747foreign export ccall "pugs_UndefVal" 
     
    126126nvToVal = mkVal . VNum . realToFrac 
    127127 
    128 pvToVal :: CString -> IO PugsVal 
    129 pvToVal cstr = do 
    130     str <- peekCString cstr 
    131     ptr <- mkVal $ VStr str 
     128pvnToVal :: CString -> CInt -> IO PugsVal 
     129pvnToVal cstr len = do 
     130    str <- peekCStringLen (cstr, fromEnum len) 
     131    ptr <- mkVal $ VStr (decodeUTF8 str) 
    132132    return ptr 
    133133