[p4perl] P4Perl Bug?

Bob Bell belvis at apple.com
Fri Dec 7 20:00:57 PST 2007


Hi,

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?

Thanks,

Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4perl/attachments/20071207/eb61ac6d/attachment-0001.html>


More information about the p4perl mailing list