[vlc-commits] modules: move text domain to plugin
Rémi Denis-Courmont
git at videolan.org
Thu Oct 27 09:51:34 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 27 10:18:10 2016 +0300| [da6d40de2002ddbda0d26e6f5a25e7c627f1363f] | committer: Rémi Denis-Courmont
modules: move text domain to plugin
Separate text domains for modules in the same library would not make
much sense, and it was never supported.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=da6d40de2002ddbda0d26e6f5a25e7c627f1363f
---
src/modules/cache.c | 15 ++++++++-------
src/modules/entry.c | 8 +++-----
src/modules/modules.c | 4 +---
src/modules/modules.h | 3 ++-
4 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/modules/cache.c b/src/modules/cache.c
index a7d2538..bf6db35 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -57,7 +57,7 @@
#ifdef HAVE_DYNAMIC_PLUGINS
/* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */
-#define CACHE_SUBVERSION_NUM 27
+#define CACHE_SUBVERSION_NUM 28
/* Cache filename */
#define CACHE_NAME "plugins.dat"
@@ -314,10 +314,6 @@ static module_t *vlc_cache_load_module(vlc_plugin_t *plugin, block_t *file)
LOAD_IMMEDIATE(module->i_score);
LOAD_IMMEDIATE(module->b_unloadable);
- LOAD_STRING(module->domain);
- if (module->domain != NULL)
- vlc_bindtextdomain (module->domain);
-
uint32_t submodules;
LOAD_IMMEDIATE(submodules);
@@ -362,6 +358,8 @@ static vlc_plugin_t *vlc_cache_load_plugin(block_t *file)
if (vlc_cache_load_plugin_config(plugin, file))
goto error;
+ LOAD_STRING(plugin->textdomain);
+
const char *path;
LOAD_STRING(path);
if (path == NULL)
@@ -373,6 +371,10 @@ static vlc_plugin_t *vlc_cache_load_plugin(block_t *file)
LOAD_IMMEDIATE(plugin->mtime);
LOAD_IMMEDIATE(plugin->size);
+
+ if (plugin->textdomain != NULL)
+ vlc_bindtextdomain(plugin->textdomain);
+
return plugin;
error:
@@ -650,8 +652,6 @@ static int CacheSaveBank(FILE *file, vlc_plugin_t *const *cache, size_t n)
SAVE_IMMEDIATE(module->i_score);
SAVE_IMMEDIATE(module->b_unloadable);
- SAVE_STRING(module->domain);
-
i_submodule = module->submodule_count;
SAVE_IMMEDIATE( i_submodule );
if (CacheSaveSubmodule (file, module->submodule))
@@ -662,6 +662,7 @@ static int CacheSaveBank(FILE *file, vlc_plugin_t *const *cache, size_t n)
goto error;
/* Save common info */
+ SAVE_STRING(plugin->textdomain);
SAVE_STRING(plugin->path);
SAVE_IMMEDIATE(plugin->mtime);
SAVE_IMMEDIATE(plugin->size);
diff --git a/src/modules/entry.c b/src/modules/entry.c
index 52a0468..d0e4795 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -69,7 +69,6 @@ module_t *vlc_module_create(vlc_plugin_t *plugin)
module->pf_deactivate = NULL;
/*module->handle = garbage */
module->psz_filename = NULL;
- module->domain = NULL;
return module;
}
@@ -99,7 +98,7 @@ vlc_plugin_t *vlc_plugin_create(void)
plugin->path = NULL;
plugin->module = NULL;
-
+ plugin->textdomain = NULL;
plugin->conf.items = NULL;
plugin->conf.size = 0;
plugin->conf.count = 0;
@@ -297,9 +296,8 @@ static int vlc_plugin_setter(void *ctx, void *tgt, int propid, ...)
break;
case VLC_MODULE_TEXTDOMAIN:
- assert(module->plugin->module == NULL);
- assert (module->domain == NULL);
- module->domain = va_arg (ap, const char *);
+ assert(plugin->textdomain == NULL);
+ plugin->textdomain = va_arg(ap, const char *);
break;
case VLC_CONFIG_NAME:
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 4f72e59..62b50a8 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -127,12 +127,10 @@ int module_get_score( const module_t *m )
*/
const char *module_gettext (const module_t *m, const char *str)
{
- m = m->plugin->module;
-
if (unlikely(str == NULL || *str == '\0'))
return "";
#ifdef ENABLE_NLS
- const char *domain = m->domain;
+ const char *domain = m->plugin->textdomain;
return dgettext ((domain != NULL) ? domain : PACKAGE_NAME, str);
#else
(void)m;
diff --git a/src/modules/modules.h b/src/modules/modules.h
index a586e0b..7cf89b8 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -35,6 +35,8 @@ typedef struct vlc_plugin_t
module_t *module;
+ const char *textdomain; /**< gettext domain (or NULL) */
+
/**
* Variables set by the module to store its config options
*/
@@ -100,7 +102,6 @@ struct module_t
/* Plugin-specific stuff */
module_handle_t handle; /* Unique handle */
char * psz_filename; /* Module filename */
- const char * domain; /* gettext domain */
};
vlc_plugin_t *vlc_plugin_create(void);
More information about the vlc-commits
mailing list