~ubuntu-branches/ubuntu/hardy/gnupg2/hardy

« back to all changes in this revision

Viewing changes to intl/bindtextdom.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia, Michael Bienia, Kees Cook
  • Date: 2006-12-07 00:28:23 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061207002823-0i7ittrpmsm1nv0i
Tags: 2.0.1-0ubuntu1
[ Michael Bienia ]
* New upstream version.
* Remaining changes:
  - Remove libpcsclite-dev, libopensc2-dev build dependencies (they are in
    universe).
* g10/encr-data.c: remotely controllable function pointer (CVE-2006-6235)
* debian/control: add libcurl3-gnutls-dev to build-depends 
  (Closes Ubuntu: #62864)

[ Kees Cook ]
* debian/rules: include doc/ files as done with gnupg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Implementation of the bindtextdomain(3) function
2
 
   Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
 
2
   Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software; you can redistribute it and/or modify it
5
5
   under the terms of the GNU Library General Public License as published
13
13
 
14
14
   You should have received a copy of the GNU Library General Public
15
15
   License along with this program; if not, write to the Free Software
16
 
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
17
   USA.  */
18
18
 
19
19
#ifdef HAVE_CONFIG_H
24
24
#include <stdlib.h>
25
25
#include <string.h>
26
26
 
 
27
#include "gettextP.h"
27
28
#ifdef _LIBC
28
29
# include <libintl.h>
29
30
#else
30
31
# include "libgnuintl.h"
31
32
#endif
32
 
#include "gettextP.h"
33
33
 
 
34
/* Handle multi-threaded applications.  */
34
35
#ifdef _LIBC
35
 
/* We have to handle multi-threaded applications.  */
36
36
# include <bits/libc-lock.h>
 
37
# define gl_rwlock_define __libc_rwlock_define
 
38
# define gl_rwlock_wrlock __libc_rwlock_wrlock
 
39
# define gl_rwlock_unlock __libc_rwlock_unlock
37
40
#else
38
 
/* Provide dummy implementation if this is outside glibc.  */
39
 
# define __libc_rwlock_define(CLASS, NAME)
40
 
# define __libc_rwlock_wrlock(NAME)
41
 
# define __libc_rwlock_unlock(NAME)
 
41
# include "lock.h"
42
42
#endif
43
43
 
44
44
/* The internal variables in the standalone libintl.a must have different
59
59
/* Contains the default location of the message catalogs.  */
60
60
extern const char _nl_default_dirname[];
61
61
#ifdef _LIBC
62
 
extern const char _nl_default_dirname_internal[] attribute_hidden;
63
 
#else
64
 
# define INTUSE(name) name
 
62
libc_hidden_proto (_nl_default_dirname)
65
63
#endif
66
64
 
67
65
/* List with bindings of specific domains.  */
68
66
extern struct binding *_nl_domain_bindings;
69
67
 
70
68
/* Lock variable to protect the global data in the gettext implementation.  */
71
 
__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
 
69
gl_rwlock_define (extern, _nl_state_lock attribute_hidden)
72
70
 
73
71
 
74
72
/* Names for the libintl functions are a problem.  They must not clash
109
107
      return;
110
108
    }
111
109
 
112
 
  __libc_rwlock_wrlock (_nl_state_lock);
 
110
  gl_rwlock_wrlock (_nl_state_lock);
113
111
 
114
112
  modified = 0;
115
113
 
144
142
              char *result = binding->dirname;
145
143
              if (strcmp (dirname, result) != 0)
146
144
                {
147
 
                  if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
148
 
                    result = (char *) INTUSE(_nl_default_dirname);
 
145
                  if (strcmp (dirname, _nl_default_dirname) == 0)
 
146
                    result = (char *) _nl_default_dirname;
149
147
                  else
150
148
                    {
151
149
#if defined _LIBC || defined HAVE_STRDUP
160
158
 
161
159
                  if (__builtin_expect (result != NULL, 1))
162
160
                    {
163
 
                      if (binding->dirname != INTUSE(_nl_default_dirname))
 
161
                      if (binding->dirname != _nl_default_dirname)
164
162
                        free (binding->dirname);
165
163
 
166
164
                      binding->dirname = result;
201
199
                        free (binding->codeset);
202
200
 
203
201
                      binding->codeset = result;
204
 
                      binding->codeset_cntr++;
205
202
                      modified = 1;
206
203
                    }
207
204
                }
214
211
    {
215
212
      /* Simply return the default values.  */
216
213
      if (dirnamep)
217
 
        *dirnamep = INTUSE(_nl_default_dirname);
 
214
        *dirnamep = _nl_default_dirname;
218
215
      if (codesetp)
219
216
        *codesetp = NULL;
220
217
    }
236
233
 
237
234
          if (dirname == NULL)
238
235
            /* The default value.  */
239
 
            dirname = INTUSE(_nl_default_dirname);
 
236
            dirname = _nl_default_dirname;
240
237
          else
241
238
            {
242
 
              if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
243
 
                dirname = INTUSE(_nl_default_dirname);
 
239
              if (strcmp (dirname, _nl_default_dirname) == 0)
 
240
                dirname = _nl_default_dirname;
244
241
              else
245
242
                {
246
243
                  char *result;
263
260
        }
264
261
      else
265
262
        /* The default value.  */
266
 
        new_binding->dirname = (char *) INTUSE(_nl_default_dirname);
267
 
 
268
 
      new_binding->codeset_cntr = 0;
 
263
        new_binding->dirname = (char *) _nl_default_dirname;
269
264
 
270
265
      if (codesetp)
271
266
        {
287
282
              memcpy (result, codeset, len);
288
283
#endif
289
284
              codeset = result;
290
 
              new_binding->codeset_cntr++;
291
285
            }
292
286
          *codesetp = codeset;
293
287
          new_binding->codeset = (char *) codeset;
319
313
      if (0)
320
314
        {
321
315
        failed_codeset:
322
 
          if (new_binding->dirname != INTUSE(_nl_default_dirname))
 
316
          if (new_binding->dirname != _nl_default_dirname)
323
317
            free (new_binding->dirname);
324
318
        failed_dirname:
325
319
          free (new_binding);
335
329
  if (modified)
336
330
    ++_nl_msg_cat_cntr;
337
331
 
338
 
  __libc_rwlock_unlock (_nl_state_lock);
 
332
  gl_rwlock_unlock (_nl_state_lock);
339
333
}
340
334
 
341
335
/* Specify that the DOMAINNAME message catalog will be found