aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-06-28 12:05:25 +0200
committerChristian Grothoff <christian@grothoff.org>2022-06-28 12:05:25 +0200
commit7b99bec5d82a749bf060f2eb8874678c5a6f09ab (patch)
tree46c461c8c5c7c6892a204798a012276a374fe0a5
parentb6cbb6f800ef9aeebcfb76a7ba721d4b95a2e2ca (diff)
downloadgnunet-7b99bec5d82a749bf060f2eb8874678c5a6f09ab.tar.gz
gnunet-7b99bec5d82a749bf060f2eb8874678c5a6f09ab.zip
-do gettext setup for each library/domain, not only once
-rw-r--r--src/util/os_installation.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 171bb5baa..1835c6e84 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2006-2018 GNUnet e.V. 3 Copyright (C) 2006-2018, 2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -80,11 +80,12 @@ static const struct GNUNET_OS_ProjectData default_pd = {
80static const struct GNUNET_OS_ProjectData *current_pd = &default_pd; 80static const struct GNUNET_OS_ProjectData *current_pd = &default_pd;
81 81
82/** 82/**
83 * Whether or not gettext has been initialized for the library. 83 * PD for which gettext has been initialized last.
84 * Note that the gettext initialization done within 84 * Note that the gettext initialization done within
85 * GNUNET_PROGRAM_run2 is for the specific application. 85 * GNUNET_PROGRAM_run2 is for the specific application.
86 */ 86 */
87static int gettextinit = 0; 87static const struct GNUNET_OS_ProjectData *gettextinit;
88
88 89
89/** 90/**
90 * Return default project data used by 'libgnunetutil' for GNUnet. 91 * Return default project data used by 'libgnunetutil' for GNUnet.
@@ -102,13 +103,15 @@ GNUNET_OS_project_data_default (void)
102const struct GNUNET_OS_ProjectData * 103const struct GNUNET_OS_ProjectData *
103GNUNET_OS_project_data_get () 104GNUNET_OS_project_data_get ()
104{ 105{
105 if (0 == gettextinit) 106 if (current_pd != gettextinit)
106 { 107 {
107 char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR); 108 char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
109
108 if (NULL != path) 110 if (NULL != path)
109 bindtextdomain (PACKAGE, path); 111 bindtextdomain (PACKAGE,
112 path);
110 GNUNET_free (path); 113 GNUNET_free (path);
111 gettextinit = 1; 114 gettextinit = current_pd;
112 } 115 }
113 return current_pd; 116 return current_pd;
114} 117}
@@ -122,16 +125,18 @@ GNUNET_OS_project_data_get ()
122void 125void
123GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd) 126GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd)
124{ 127{
125 if (0 == gettextinit) 128 GNUNET_assert (NULL != pd);
129 current_pd = pd;
130 if (pd != gettextinit)
126 { 131 {
127 char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR); 132 char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
133
128 if (NULL != path) 134 if (NULL != path)
129 bindtextdomain (PACKAGE, path); 135 bindtextdomain (PACKAGE,
136 path);
130 GNUNET_free (path); 137 GNUNET_free (path);
131 gettextinit = 1; 138 gettextinit = pd;
132 } 139 }
133 GNUNET_assert (NULL != pd);
134 current_pd = pd;
135} 140}
136 141
137 142