From 40ed01f6f2e8d32e94f71dd19ebe71d9c5d5e556 Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 20 Jul 2006 09:11:49 +1000 Subject: [PATCH] Move a few pieces of implementation-specific kludges related to different gettext implementations out of env.c and into fallback.c darcs-hash:20060719231149-ac50b-c930a77ae76249b27f800f1d61146482c8f005c9.gz --- env.c | 25 +++++++++++++++---------- fallback.c | 17 +++++++++++++++++ fallback.h | 44 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/env.c b/env.c index 2729af8f4..22984ace6 100644 --- a/env.c +++ b/env.c @@ -31,6 +31,10 @@ #include #endif +#if HAVE_LIBINTL_H +#include +#endif + #include @@ -305,16 +309,17 @@ static void handle_locale() if( wcscmp( wsetlocale( LC_MESSAGES, (void *)0 ), old ) != 0 ) { - /* Try to make change known to gettext. */ -#ifdef HAVE__NL_MSG_CAT_CNTR - { - extern int _nl_msg_cat_cntr; - ++_nl_msg_cat_cntr; - } -#elif HAVE_DCGETTEXT - dcgettext("fish","Changing language to English",LC_MESSAGES); -#endif - + /* + Try to make change known to gettext. Both changing + _nl_msg_cat_cntr and calling dcgettext might potentially + tell some gettext implementation that the translation + strings should be reloaded. We do both and hope for the + best. + */ + extern int _nl_msg_cat_cntr; + ++_nl_msg_cat_cntr; + dcgettext( "fish", "Changing language to English", LC_MESSAGES ); + if( is_interactive ) { debug( 0, _(L"Changing language to English") ); diff --git a/fallback.c b/fallback.c index cad56171f..d85635664 100644 --- a/fallback.c +++ b/fallback.c @@ -1050,4 +1050,21 @@ char * textdomain (const char * domainname) #endif +#ifndef HAVE_DCGETTEXT + +char * dcgettext ( const char * domainname, + const char * msgid, + int category) +{ + return msgid; +} + + +#endif + +#ifndef HAVE__NL_MSG_CAT_CNTR + +int _nl_msg_cat_cntr=0; + +#endif diff --git a/fallback.h b/fallback.h index 4ad55cfaa..6bfaed635 100644 --- a/fallback.h +++ b/fallback.h @@ -310,29 +310,61 @@ struct drand48_data /** Fallback implementation of lrand48_r. Internally uses rand_r, so it is pretty weak. */ -int lrand48_r(struct drand48_data *buffer, long int *result); +int lrand48_r( struct drand48_data *buffer, long int *result ); /** Fallback implementation of srand48_r, the seed function for lrand48_r. */ -int srand48_r(long int seedval, struct drand48_data *buffer); +int srand48_r( long int seedval, struct drand48_data *buffer ); #endif #ifndef HAVE_FUTIMES -int futimes(int fd, const struct timeval *times); +int futimes( int fd, const struct timeval *times ); #endif #ifndef HAVE_GETTEXT -char * gettext (const char * msgid); -char * bindtextdomain (const char * domainname, const char * dirname); -char * textdomain (const char * domainname); +/** + Fallback implementation of gettext. Just returns the original string. +*/ +char * gettext( const char * msgid ); + +/** + Fallback implementation of bindtextdomain. Does nothing. +*/ +char * bindtextdomain( const char * domainname, const char * dirname ); + +/** + Fallback implementation of textdomain. Does nothing. +*/ +char * textdomain( const char * domainname ); #endif +#ifndef HAVE_DCGETTEXT + +/** + Fallback implementation of dcgettext. Just returns the original string. +*/ +char * dcgettext ( const char * domainname, + const char * msgid, + int category ); + +#endif + +#ifndef HAVE__NL_MSG_CAT_CNTR + +/** + Some gettext implementation use have this variable, and by + increasing it, one can tell the system that the translations need + to be reloaded. +*/ +extern int _nl_msg_cat_cntr; + +#endif #endif