[p4perl] P4Perl Bug?

Tony Smith tony at smee.org
Sat Dec 8 01:23:04 PST 2007


Hi Bob,
>
> I wanted to ask about an issue I ran into when using the P4 Perl API 
> to convert a Perforce depot to Subversion (via the p42svn script). I 
> had trouble converting Unicode text files. What happened was that 
> eventually, the Unicode text of the file comes through this member 
> function:
>
> PerlClientUser::OutputText( const_char *data, int length )
> {
>     if ( P4PERL_DEBUG_FLOW )
> printf( "[PerlClientUser::OutputText]: Received %d bytes\n", length );
>
>     results.AddOutput( data );
> }
>
> The Unicode data has lots of nul characters in it, so even though 
> "length" might be some large number, the data gets discarded after the 
> first nul because the version of AddOutput called here treats it like 
> a nul-terminated string. I don't know why PerlClientUser::OutputText() 
> was being called in this case instead of 
> the PerlClientUser::OutputBinary() function, but my workaround was to 
> change PerlClientUser::OutputText() to
>
> void
> PerlClientUser::OutputText( const_char *data, int length )
> {
>     if ( P4PERL_DEBUG_FLOW )
> printf( "[PerlClientUser::OutputText]: Received %d bytes\n", length );
>
>     results.AddOutput( newSVpv( data, length) );
> }
>
> This made the problem go away, and didn't seem to cause any other 
> problems.
>
> Does this look like a reasonable workaround? Is my problem coming from 
> some other source?
Yes, it looks like just the right fix for the problem. Thanks very much 
for sending it in.

Tony



More information about the p4perl mailing list