-/*****************************************************************************
- * ConvertPrintfFormatString: replace all occurrences of %ll with %I64 in the
- * printf format string.
- *****************************************************************************
- * Win32 doesn't recognize the "%ll" format in a printf string, so we have
- * to convert this string to something that win32 can handle.
- * This is a REALLY UGLY HACK which won't even work in every situation,
- * but hey I don't want to put an ifdef WIN32 each time I use printf with
- * a "long long" type!!!
- * By the way, if we don't do this we can sometimes end up with segfaults.
- *****************************************************************************/
-#if defined( WIN32 )
-static char *ConvertPrintfFormatString( const char *psz_format )
-{
- int i, i_counter=0, i_pos=0;
- char *psz_dest;
-
- /* We first need to check how many occurences of %ll there are in the
- * psz_format string. Once we'll know that we'll be able to malloc the
- * destination string */
-
- if( strlen( psz_format ) <= 3 )
- return strdup( psz_format );
-
- for( i=0; i <= (strlen(psz_format) - 3); i++ )
- {
- if( !strncmp( (char *)(psz_format + i), "%ll", 3 ) )
- {
- i_counter++;
- }
- }
-
- /* malloc the destination string */
- psz_dest = malloc( strlen(psz_format) + i_counter + 1 );
- if( psz_dest == NULL )
- {
- fprintf( stderr, "main warning: ConvertPrintfFormatString failed\n" );
- return NULL;
- }
-
- /* Now build the modified string */
- i_counter = 0;
- for( i=0; i <= (strlen(psz_format) - 3); i++ )
- {
- if( !strncmp( (char *)(psz_format + i), "%ll", 3 ) )
- {
- memcpy( psz_dest+i_pos+i_counter, psz_format+i_pos, i-i_pos+1);
- *(psz_dest+i+i_counter+1)='I';
- *(psz_dest+i+i_counter+2)='6';
- *(psz_dest+i+i_counter+3)='4';
- i_pos = i+3;
- i_counter++;
- }
- }
- strcpy( psz_dest+i_pos+i_counter, psz_format+i_pos );
-
- return psz_dest;
-}