mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk) #3311 "MingW build of Transmission" -- modify tr_strip_positional_args() to strip out the ' printf flag. Platforms not supporting $ tend to not support ' either
This commit is contained in:
parent
41f9ae0500
commit
1f3ead026d
3 changed files with 32 additions and 7 deletions
|
@ -102,6 +102,28 @@ test_bitfields( void )
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_strip_positional_args( void )
|
||||
{
|
||||
const char * in;
|
||||
const char * out;
|
||||
const char * expected;
|
||||
|
||||
in = "Hello %1$s foo %2$.*f";
|
||||
expected = "Hello %s foo %.*f";
|
||||
out = tr_strip_positional_args( in );
|
||||
check( out != NULL )
|
||||
check( !strcmp( out, expected ) )
|
||||
|
||||
in = "Hello %1$'d foo %2$'f";
|
||||
expected = "Hello %d foo %f";
|
||||
out = tr_strip_positional_args( in );
|
||||
check( out != NULL )
|
||||
check( !strcmp( out, expected ) )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_strstrip( void )
|
||||
{
|
||||
|
@ -392,6 +414,8 @@ main( void )
|
|||
return i;
|
||||
if( ( i = test_lowerbound( ) ) )
|
||||
return i;
|
||||
if( ( i = test_strip_positional_args( ) ) )
|
||||
return i;
|
||||
if( ( i = test_strstrip( ) ) )
|
||||
return i;
|
||||
if( ( i = test_buildpath( ) ) )
|
||||
|
|
|
@ -404,8 +404,6 @@ tr_set_compare( const void * va,
|
|||
****
|
||||
***/
|
||||
|
||||
#ifdef DISABLE_GETTEXT
|
||||
|
||||
const char*
|
||||
tr_strip_positional_args( const char* str )
|
||||
{
|
||||
|
@ -424,23 +422,25 @@ tr_strip_positional_args( const char* str )
|
|||
for( out = buf; *str; ++str )
|
||||
{
|
||||
*out++ = *str;
|
||||
|
||||
if( ( *str == '%' ) && isdigit( str[1] ) )
|
||||
{
|
||||
const char * tmp = str + 1;
|
||||
while( isdigit( *tmp ) )
|
||||
++tmp;
|
||||
|
||||
if( *tmp == '$' )
|
||||
str = tmp;
|
||||
str = tmp[1]=='\'' ? tmp+1 : tmp;
|
||||
}
|
||||
|
||||
if( ( *str == '%' ) && ( str[1] == '\'' ) )
|
||||
str = str + 1;
|
||||
|
||||
}
|
||||
*out = '\0';
|
||||
|
||||
return strcmp( buf, in ) ? buf : in;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
|
|
@ -88,6 +88,8 @@ extern "C" {
|
|||
****
|
||||
***/
|
||||
|
||||
const char * tr_strip_positional_args( const char * fmt );
|
||||
|
||||
#if !defined( _ )
|
||||
#if defined( HAVE_LIBINTL_H ) && !defined( SYS_DARWIN )
|
||||
#include <libintl.h>
|
||||
|
@ -104,7 +106,6 @@ extern "C" {
|
|||
#endif
|
||||
#endif
|
||||
#ifdef DISABLE_GETTEXT
|
||||
const char * tr_strip_positional_args( const char * fmt );
|
||||
#undef _
|
||||
#define _( a ) tr_strip_positional_args( a )
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue