Changeset 10844
- Timestamp:
- Jun 25, 2010, 1:13:35 AM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/utils-test.c
r10239 r10844 104 104 105 105 static int 106 test_strip_positional_args( void ) 107 { 108 const char * in; 109 const char * out; 110 const char * expected; 111 112 in = "Hello %1$s foo %2$.*f"; 113 expected = "Hello %s foo %.*f"; 114 out = tr_strip_positional_args( in ); 115 check( out != NULL ) 116 check( !strcmp( out, expected ) ) 117 118 in = "Hello %1$'d foo %2$'f"; 119 expected = "Hello %d foo %f"; 120 out = tr_strip_positional_args( in ); 121 check( out != NULL ) 122 check( !strcmp( out, expected ) ) 123 124 return 0; 125 } 126 127 static int 106 128 test_strstrip( void ) 107 129 { … … 393 415 if( ( i = test_lowerbound( ) ) ) 394 416 return i; 417 if( ( i = test_strip_positional_args( ) ) ) 418 return i; 395 419 if( ( i = test_strstrip( ) ) ) 396 420 return i; -
trunk/libtransmission/utils.c
r10837 r10844 405 405 ***/ 406 406 407 #ifdef DISABLE_GETTEXT408 409 407 const char* 410 408 tr_strip_positional_args( const char* str ) … … 425 423 { 426 424 *out++ = *str; 425 427 426 if( ( *str == '%' ) && isdigit( str[1] ) ) 428 427 { … … 430 429 while( isdigit( *tmp ) ) 431 430 ++tmp; 432 433 431 if( *tmp == '$' ) 434 str = tmp ;432 str = tmp[1]=='\'' ? tmp+1 : tmp; 435 433 } 434 435 if( ( *str == '%' ) && ( str[1] == '\'' ) ) 436 str = str + 1; 437 436 438 } 437 439 *out = '\0'; … … 439 441 return strcmp( buf, in ) ? buf : in; 440 442 } 441 442 #endif443 443 444 444 /** -
trunk/libtransmission/utils.h
r10822 r10844 89 89 ***/ 90 90 91 const char * tr_strip_positional_args( const char * fmt ); 92 91 93 #if !defined( _ ) 92 94 #if defined( HAVE_LIBINTL_H ) && !defined( SYS_DARWIN ) … … 105 107 #endif 106 108 #ifdef DISABLE_GETTEXT 107 const char * tr_strip_positional_args( const char * fmt );108 109 #undef _ 109 110 #define _( a ) tr_strip_positional_args( a )
Note: See TracChangeset
for help on using the changeset viewer.