From: Charles Kerr Date: Thu, 21 Aug 2008 21:04:57 +0000 (+0000) Subject: * add DISABLE_GETTEXT preprocessor directive to turn off i18n in libtransmission... X-Git-Tag: 1.40~435 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e4fb99f8cf11a824d4c4f57e825ef80b75dee2e;p=transmission * add DISABLE_GETTEXT preprocessor directive to turn off i18n in libtransmission for embedded devices. * remove `wchar.h' #include from shttpd that broke the compile on embedded devices. --- diff --git a/libtransmission/utils.c b/libtransmission/utils.c index 1789728d5..da494ecc5 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -357,6 +357,41 @@ tr_strcasecmp( const char * a, const char * b ) #endif } +/** +*** +**/ + +#ifdef DISABLE_GETTEXT + +const char* +tr_strip_positional_args( const char* str ) +{ + static size_t bufsize = 0; + static char * buf = NULL; + const size_t len = strlen( str ); + char * out; + + if( bufsize < len ) { + bufsize = len * 2; + buf = tr_renew( char, buf, bufsize ); + } + + 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; + } + } + *out = '\0'; + + return buf; +} + +#endif /** *** diff --git a/libtransmission/utils.h b/libtransmission/utils.h index bb02d853c..10643e74a 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -91,6 +91,13 @@ #endif #endif +/* #define DISABLE_GETTEXT */ +#ifdef DISABLE_GETTEXT +const char* tr_strip_positional_args( const char* fmt ); +#undef _ +#define _(a) tr_strip_positional_args(a) +#endif + #define tr_nerr( n, a... ) tr_msg( __FILE__, __LINE__, TR_MSG_ERR, n, ## a ) #define tr_ninf( n, a... ) tr_msg( __FILE__, __LINE__, TR_MSG_INF, n, ## a ) #define tr_ndbg( n, a... ) tr_msg( __FILE__, __LINE__, TR_MSG_DBG, n, ## a ) diff --git a/third-party/shttpd/std_includes.h b/third-party/shttpd/std_includes.h index f61503ce6..4bf1ea7b6 100644 --- a/third-party/shttpd/std_includes.h +++ b/third-party/shttpd/std_includes.h @@ -28,7 +28,6 @@ #include #include #include -#include #if defined(_WIN32) /* Windows specific */ #include "compat_win32.h"