~ubuntu-branches/ubuntu/maverick/texinfo/maverick

« back to all changes in this revision

Viewing changes to intl/bindtextdom.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2005-10-28 15:10:30 UTC
  • mto: (2.1.1 dapper) (3.1.4 hardy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051028151030-9nsf2s2k2z3fktjt
Tags: upstream-4.8
ImportĀ upstreamĀ versionĀ 4.8

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, 2001 Free Software Foundation, Inc.
 
2
   Copyright (C) 1995-1998, 2000-2003 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
45
45
   names than the internal variables in GNU libc, otherwise programs
46
46
   using libintl.a cannot be linked statically.  */
47
47
#if !defined _LIBC
48
 
# define _nl_default_dirname _nl_default_dirname__
49
 
# define _nl_domain_bindings _nl_domain_bindings__
 
48
# define _nl_default_dirname libintl_nl_default_dirname
 
49
# define _nl_domain_bindings libintl_nl_domain_bindings
50
50
#endif
51
51
 
52
52
/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>.  */
58
58
 
59
59
/* Contains the default location of the message catalogs.  */
60
60
extern const char _nl_default_dirname[];
 
61
#ifdef _LIBC
 
62
extern const char _nl_default_dirname_internal[] attribute_hidden;
 
63
#else
 
64
# define INTUSE(name) name
 
65
#endif
61
66
 
62
67
/* List with bindings of specific domains.  */
63
68
extern struct binding *_nl_domain_bindings;
64
69
 
65
70
/* Lock variable to protect the global data in the gettext implementation.  */
66
 
__libc_rwlock_define (extern, _nl_state_lock)
 
71
__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
67
72
 
68
73
 
69
74
/* Names for the libintl functions are a problem.  They must not clash
77
82
#  define strdup(str) __strdup (str)
78
83
# endif
79
84
#else
80
 
# define BINDTEXTDOMAIN bindtextdomain__
81
 
# define BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset__
 
85
# define BINDTEXTDOMAIN libintl_bindtextdomain
 
86
# define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset
82
87
#endif
83
88
 
84
 
/* Prototypes for local functions.  */
85
 
static void set_binding_values PARAMS ((const char *domainname,
86
 
                                        const char **dirnamep,
87
 
                                        const char **codesetp));
88
 
 
89
89
/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
90
90
   to be used for the DOMAINNAME message catalog.
91
91
   If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
93
93
   If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither
94
94
   modified nor returned.  */
95
95
static void
96
 
set_binding_values (domainname, dirnamep, codesetp)
97
 
     const char *domainname;
98
 
     const char **dirnamep;
99
 
     const char **codesetp;
 
96
set_binding_values (const char *domainname,
 
97
                    const char **dirnamep, const char **codesetp)
100
98
{
101
99
  struct binding *binding;
102
100
  int modified;
146
144
              char *result = binding->dirname;
147
145
              if (strcmp (dirname, result) != 0)
148
146
                {
149
 
                  if (strcmp (dirname, _nl_default_dirname) == 0)
150
 
                    result = (char *) _nl_default_dirname;
 
147
                  if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
 
148
                    result = (char *) INTUSE(_nl_default_dirname);
151
149
                  else
152
150
                    {
153
151
#if defined _LIBC || defined HAVE_STRDUP
162
160
 
163
161
                  if (__builtin_expect (result != NULL, 1))
164
162
                    {
165
 
                      if (binding->dirname != _nl_default_dirname)
 
163
                      if (binding->dirname != INTUSE(_nl_default_dirname))
166
164
                        free (binding->dirname);
167
165
 
168
166
                      binding->dirname = result;
216
214
    {
217
215
      /* Simply return the default values.  */
218
216
      if (dirnamep)
219
 
        *dirnamep = _nl_default_dirname;
 
217
        *dirnamep = INTUSE(_nl_default_dirname);
220
218
      if (codesetp)
221
219
        *codesetp = NULL;
222
220
    }
238
236
 
239
237
          if (dirname == NULL)
240
238
            /* The default value.  */
241
 
            dirname = _nl_default_dirname;
 
239
            dirname = INTUSE(_nl_default_dirname);
242
240
          else
243
241
            {
244
 
              if (strcmp (dirname, _nl_default_dirname) == 0)
245
 
                dirname = _nl_default_dirname;
 
242
              if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
 
243
                dirname = INTUSE(_nl_default_dirname);
246
244
              else
247
245
                {
248
246
                  char *result;
265
263
        }
266
264
      else
267
265
        /* The default value.  */
268
 
        new_binding->dirname = (char *) _nl_default_dirname;
 
266
        new_binding->dirname = (char *) INTUSE(_nl_default_dirname);
269
267
 
270
268
      new_binding->codeset_cntr = 0;
271
269
 
321
319
      if (0)
322
320
        {
323
321
        failed_codeset:
324
 
          if (new_binding->dirname != _nl_default_dirname)
 
322
          if (new_binding->dirname != INTUSE(_nl_default_dirname))
325
323
            free (new_binding->dirname);
326
324
        failed_dirname:
327
325
          free (new_binding);
343
341
/* Specify that the DOMAINNAME message catalog will be found
344
342
   in DIRNAME rather than in the system locale data base.  */
345
343
char *
346
 
BINDTEXTDOMAIN (domainname, dirname)
347
 
     const char *domainname;
348
 
     const char *dirname;
 
344
BINDTEXTDOMAIN (const char *domainname, const char *dirname)
349
345
{
350
346
  set_binding_values (domainname, &dirname, NULL);
351
347
  return (char *) dirname;
354
350
/* Specify the character encoding in which the messages from the
355
351
   DOMAINNAME message catalog will be returned.  */
356
352
char *
357
 
BIND_TEXTDOMAIN_CODESET (domainname, codeset)
358
 
     const char *domainname;
359
 
     const char *codeset;
 
353
BIND_TEXTDOMAIN_CODESET (const char *domainname, const char *codeset)
360
354
{
361
355
  set_binding_values (domainname, NULL, &codeset);
362
356
  return (char *) codeset;