MCPcopy Create free account
hub / github.com/Sinflower/WolfDec / CL_vsprintf

Function CL_vsprintf

src/WolfDec/3rdParty/CharCode.cpp:4579–5071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4577}
4578
4579extern int CL_vsprintf( int CharCodeFormat, char *Buffer, const char *FormatString, va_list Arg )
4580{
4581 int i ;
4582 int DestSize ;
4583 int WriteBytes ;
4584 u32 BaseBuffer[ 1024 ] ;
4585 u32 *TempBuffer = NULL ;
4586 u32 *FCode ;
4587 int FormatStringSize ;
4588
4589 // 1文字4バイト形式に変換する
4590 FormatStringSize = StringToCharCodeString_inline( FormatString, CharCodeFormat, NULL ) ;
4591 if( FormatStringSize + sizeof( u32 ) * 16 > sizeof( BaseBuffer ) )
4592 {
4593 TempBuffer = ( u32 * )malloc( FormatStringSize + sizeof( u32 ) * 16 ) ;
4594 if( TempBuffer == NULL )
4595 {
4596 return -1 ;
4597 }
4598
4599 FCode = TempBuffer ;
4600 }
4601 else
4602 {
4603 FCode = BaseBuffer ;
4604 }
4605 memset( FCode, 0, FormatStringSize + sizeof( u32 ) * 16 ) ;
4606 StringToCharCodeString_inline( FormatString, CharCodeFormat, FCode ) ;
4607
4608 DestSize = 0 ;
4609 for( i = 0 ; FCode[ i ] != 0 ; )
4610 {
4611 if( FCode[ i ] == 0x25 && FCode[ i + 1 ] == 0x25 )
4612 {
4613 WriteBytes = PutCharCode_inline( 0x25, CharCodeFormat, ( char * )&( ( u8 * )Buffer )[ DestSize ] ) ;
4614 DestSize += WriteBytes ;
4615 i += 2 ;
4616 }
4617 else
4618 if( FCode[ i ] != 0x25 || FCode[ i + 1 ] == 0x25 )
4619 {
4620 WriteBytes = PutCharCode_inline( FCode[ i ], CharCodeFormat, ( char * )&( ( u8 * )Buffer )[ DestSize ] ) ;
4621 DestSize += WriteBytes ;
4622 i ++ ;
4623 }
4624 else
4625 {
4626 int Flag_Sharp = 0 ;
4627 int Flag_Zero = 0 ;
4628 int Flag_Space = 0 ;
4629 int Flag_Plus = 0 ;
4630 int Flag_Minus = 0 ;
4631 int FlagEnd = 0 ;
4632 int Width = -1 ;
4633 int Dot = 0 ;
4634 int Precision = -1 ;
4635 int PrecisionEnd = 0 ;
4636 int Prefix = -1 ;

Callers 1

CL_sprintfFunction · 0.85

Calls 8

PutCharCode_inlineFunction · 0.85
CL_vsprintf_help_cFunction · 0.85
CL_vsprintf_help_itoaFunction · 0.85
CL_vsprintf_help_ftoaFunction · 0.85
CL_vsprintf_help_sFunction · 0.85

Tested by

no test coverage detected