aboutsummaryrefslogtreecommitdiff
path: root/intl/bindtextdom.c
diff options
context:
space:
mode:
authornobody <>2004-10-18 08:06:33 +0000
committernobody <>2004-10-18 08:06:33 +0000
commit4dcf8bca5382f997a23a3ed1ba352745600e2477 (patch)
tree121248599854507bb9b8bbb87e27f8d2cd27c8ef /intl/bindtextdom.c
parent2b10a680d703ca8950444b0d6a5394f11f6b05c8 (diff)
downloadbinutils-4dcf8bca5382f997a23a3ed1ba352745600e2477.zip
binutils-4dcf8bca5382f997a23a3ed1ba352745600e2477.tar.gz
binutils-4dcf8bca5382f997a23a3ed1ba352745600e2477.tar.bz2
This commit was manufactured by cvs2svn to create tag 'drow_intercu-drow_intercu-merge-20040915
merge-20040915'. Sprout from gdb_6_3-branch 2004-10-18 08:06:32 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'gdb_6_3-branch'.' Cherrypick from master 2004-09-15 00:00:05 UTC Alan Modra <amodra@gmail.com> 'daily update': ChangeLog Makefile.in Makefile.tpl bfd/ChangeLog bfd/Makefile.am bfd/Makefile.in bfd/aclocal.m4 bfd/aout-target.h bfd/aout-tic30.c bfd/bfd-in.h bfd/bfd-in2.h bfd/bfd.c bfd/binary.c bfd/coff-rs6000.c bfd/coff64-rs6000.c bfd/coffcode.h bfd/config.bfd bfd/configure bfd/configure.in bfd/cpu-i386.c bfd/doc/ChangeLog bfd/doc/Makefile.am bfd/doc/Makefile.in bfd/dwarf2.c bfd/ecoff.c bfd/elf-bfd.h bfd/elf-eh-frame.c bfd/elf-hppa.h bfd/elf-m10300.c bfd/elf.c bfd/elf32-arm.h bfd/elf32-cris.c bfd/elf32-frv.c bfd/elf32-hppa.c bfd/elf32-i370.c bfd/elf32-i386.c bfd/elf32-m32r.c bfd/elf32-m68k.c bfd/elf32-ppc.c bfd/elf32-s390.c bfd/elf32-sh-symbian.c bfd/elf32-sh.c bfd/elf32-sh64.c bfd/elf32-sparc.c bfd/elf32-vax.c bfd/elf32-xstormy16.c bfd/elf32-xtensa.c bfd/elf64-alpha.c bfd/elf64-hppa.c bfd/elf64-mips.c bfd/elf64-ppc.c bfd/elf64-s390.c bfd/elf64-sh64.c bfd/elf64-sparc.c bfd/elf64-x86-64.c bfd/elfarm-nabi.c bfd/elflink.c bfd/elfxx-ia64.c bfd/elfxx-mips.c bfd/elfxx-target.h bfd/hash.c bfd/i386msdos.c bfd/ieee.c bfd/ihex.c bfd/libaout.h bfd/libbfd-in.h bfd/libbfd.h bfd/libecoff.h bfd/linker.c bfd/mach-o.c bfd/mmo.c bfd/nlm-target.h bfd/oasys.c bfd/opncls.c bfd/pe-i386.c bfd/pef.c bfd/pei-i386.c bfd/po/SRC-POTFILES.in bfd/po/bfd.pot bfd/ppcboot.c bfd/reloc.c bfd/simple.c bfd/som.c bfd/srec.c bfd/syms.c bfd/targets.c bfd/tekhex.c bfd/versados.c bfd/version.h bfd/vms.c bfd/xcoff-target.h bfd/xcofflink.c bfd/xsym.c bfd/xtensa-isa.c bfd/xtensa-modules.c config.guess config/ChangeLog config/gettext.m4 configure configure.in gdb/ChangeLog gdb/MAINTAINERS gdb/Makefile.in gdb/ada-exp.y gdb/ada-lang.c gdb/ada-lang.h gdb/ada-lex.l gdb/ada-typeprint.c gdb/ada-valprint.c gdb/aix-thread.c gdb/alphanbsd-tdep.c gdb/amd64-nat.h gdb/amd64bsd-nat.c gdb/amd64fbsd-nat.c gdb/amd64nbsd-nat.c gdb/amd64obsd-nat.c gdb/breakpoint.c gdb/bsd-kvm.c gdb/config.in gdb/config/alpha/alpha-linux.mh gdb/config/arm/linux.mh gdb/config/djgpp/fnchange.lst gdb/config/frv/tm-frv.h gdb/config/i386/fbsd.mh gdb/config/i386/fbsd64.mh gdb/config/i386/linux.mh gdb/config/i386/linux64.mh gdb/config/i386/nbsd64.mh gdb/config/i386/nbsdaout.mh gdb/config/i386/nbsdelf.mh gdb/config/i386/nm-fbsd.h gdb/config/i386/nm-fbsd64.h gdb/config/i386/nm-i386.h gdb/config/i386/nm-linux.h gdb/config/i386/nm-nbsdaout.h gdb/config/i386/nm-obsd.h gdb/config/i386/obsd.mh gdb/config/i386/obsd64.mh gdb/config/i386/obsdaout.mh gdb/config/ia64/linux.mh gdb/config/ia64/nm-linux.h gdb/config/m68k/linux.mh gdb/config/m88k/obsd.mh gdb/config/mips/linux.mh gdb/config/nm-linux.h gdb/config/nm-lynx.h gdb/config/pa/hpux1020.mh gdb/config/pa/hpux11.mh gdb/config/pa/hpux11w.mh gdb/config/pa/linux.mh gdb/config/powerpc/linux.mh gdb/config/powerpc/nbsd.mh gdb/config/powerpc/ppc64-linux.mh gdb/config/s390/s390.mh gdb/config/sparc/fbsd.mh gdb/config/sparc/linux.mh gdb/config/sparc/linux64.mh gdb/config/sparc/nbsd64.mh gdb/config/sparc/nbsd64.mt gdb/config/sparc/nbsdaout.mh gdb/config/sparc/nbsdelf.mh gdb/config/sparc/obsd.mt gdb/config/sparc/obsd64.mt gdb/config/vax/nbsdaout.mh gdb/config/vax/nbsdelf.mh gdb/config/vax/obsd.mh gdb/configure gdb/configure.in gdb/configure.tgt gdb/corelow.c gdb/cris-tdep.c gdb/defs.h gdb/doc/ChangeLog gdb/doc/gdb.texinfo gdb/doc/gdbint.texinfo gdb/doc/stabs.texinfo gdb/dwarf2read.c gdb/event-top.c gdb/exec.c gdb/fbsd-proc.c gdb/fork-child.c gdb/frv-tdep.c gdb/gdb_indent.sh gdb/gdb_thread_db.h gdb/gdbcmd.h gdb/gdbserver/ChangeLog gdb/gdbserver/Makefile.in gdb/gdbserver/configure gdb/gdbserver/configure.in gdb/gdbserver/linux-i386-low.c gdb/gdbserver/linux-low.c gdb/gdbserver/linux-x86-64-low.c gdb/gdbserver/proc-service.c gdb/gdbserver/remote-utils.c gdb/gdbserver/thread-db.c gdb/gdbtypes.h gdb/gnu-nat.c gdb/go32-nat.c gdb/hppa-tdep.c gdb/hppah-nat.c gdb/hpux-thread.c gdb/i386-nat.c gdb/i386-tdep.c gdb/i386bsd-nat.c gdb/i386fbsd-nat.c gdb/i386gnu-nat.c gdb/i386nbsd-nat.c gdb/ia64-linux-nat.c gdb/inf-child.c gdb/inf-ptrace.c gdb/infcall.c gdb/infptrace.c gdb/infrun.c gdb/inftarg.c gdb/infttrace.c gdb/jv-exp.y gdb/language.c gdb/lin-lwp.c gdb/linux-nat.c gdb/linux-proc.c gdb/m32r-tdep.c gdb/m88kbsd-nat.c gdb/maint.c gdb/minsyms.c gdb/mips-tdep.c gdb/monitor.c gdb/nto-procfs.c gdb/objfiles.c gdb/ppc-bdm.c gdb/procfs.c gdb/regcache.c gdb/remote-e7000.c gdb/remote-m32r-sdi.c gdb/remote-mips.c gdb/remote-rdi.c gdb/remote-rdp.c gdb/remote-sds.c gdb/remote-sim.c gdb/remote-st.c gdb/remote-vx.c gdb/remote.c gdb/rs6000-nat.c gdb/rs6000-tdep.c gdb/sh-tdep.c gdb/sh-tdep.h gdb/sol-thread.c gdb/solib-sunos.c gdb/source.c gdb/sparc-linux-tdep.c gdb/sparc-nat.c gdb/sparc-nat.h gdb/sparc64-linux-tdep.c gdb/sparc64nbsd-nat.c gdb/sparc64nbsd-tdep.c gdb/sparc64obsd-tdep.c gdb/sparcnbsd-nat.c gdb/symfile.c gdb/symtab.c gdb/target.c gdb/target.h gdb/testsuite/ChangeLog gdb/testsuite/Makefile.in gdb/testsuite/config/gdbserver.exp gdb/testsuite/configure gdb/testsuite/configure.in gdb/testsuite/gdb.asm/asm-source.exp gdb/testsuite/gdb.base/bigcore.c gdb/testsuite/gdb.base/bigcore.exp gdb/testsuite/gdb.base/constvars.exp gdb/testsuite/gdb.base/overlays.exp gdb/testsuite/gdb.base/sigstep.exp gdb/testsuite/gdb.base/volatile.exp gdb/testsuite/gdb.mi/gdb701.c gdb/testsuite/gdb.threads/bp_in_thread.exp gdb/testsuite/gdb.threads/pthread_cond_wait.exp gdb/testsuite/gdb.threads/watchthreads.exp gdb/thread-db.c gdb/top.c gdb/tui/tui-wingeneral.c gdb/utils.c gdb/uw-thread.c gdb/v850ice.c gdb/valarith.c gdb/vaxbsd-nat.c gdb/version.in gdb/win32-nat.c gdb/wince.c gdb/xstormy16-tdep.c include/ChangeLog include/bfdlink.h include/elf/ChangeLog include/elf/arm.h include/elf/common.h include/elf/dwarf2.h include/elf/x86-64.h include/elf/xtensa.h include/opcode/ChangeLog include/opcode/arm.h include/opcode/crx.h include/xtensa-config.h include/xtensa-isa-internal.h include/xtensa-isa.h install-sh intl/ChangeLog intl/Makefile.in intl/acconfig.h intl/aclocal.m4 intl/bindtextdom.c intl/cat-compat.c intl/config.in intl/configure intl/configure.in intl/dcgettext.c intl/dgettext.c intl/explodename.c intl/finddomain.c intl/gettext.c intl/gettext.h intl/gettextP.h intl/hash-string.h intl/intl-compat.c intl/intlh.inst.in intl/l10nflist.c intl/libgettext.h intl/libintl.glibc intl/linux-msg.sed intl/loadinfo.h intl/loadmsgcat.c intl/localealias.c intl/po2tbl.sed.in intl/textdomain.c intl/xopen-msg.sed ltcf-c.sh ltcf-cxx.sh ltconfig mmalloc/COPYING.LIB mmalloc/ChangeLog mmalloc/MAINTAINERS mmalloc/Makefile.in mmalloc/TODO mmalloc/acinclude.m4 mmalloc/aclocal.m4 mmalloc/attach.c mmalloc/configure mmalloc/configure.in mmalloc/detach.c mmalloc/keys.c mmalloc/mcalloc.c mmalloc/mfree.c mmalloc/mm.c mmalloc/mmalloc.c mmalloc/mmalloc.h mmalloc/mmalloc.texi mmalloc/mmap-sup.c mmalloc/mmcheck.c mmalloc/mmemalign.c mmalloc/mmprivate.h mmalloc/mmstats.c mmalloc/mmtrace.awk mmalloc/mmtrace.c mmalloc/mrealloc.c mmalloc/mvalloc.c mmalloc/sbrk-sup.c opcodes/ChangeLog opcodes/Makefile.am opcodes/Makefile.in opcodes/aclocal.m4 opcodes/arm-dis.c opcodes/arm-opc.h opcodes/configure opcodes/crx-dis.c opcodes/crx-opc.c opcodes/pdp11-dis.c opcodes/po/POTFILES.in opcodes/po/opcodes.pot opcodes/ppc-opc.c opcodes/xtensa-dis.c sim/common/ChangeLog sim/common/cgen-defs.h sim/mips/ChangeLog sim/mips/m16.igen sim/ppc/ChangeLog sim/ppc/config.in sim/ppc/configure sim/ppc/configure.in sim/ppc/emul_netbsd.c Cherrypick from cygnus 1999-05-03 07:29:11 UTC Richard Henderson <rth@redhat.com> '19990502 sourceware import': ylwrap Delete: config/codeset.m4 config/gcc-lib-path.m4 config/gettext-sister.m4 config/glibc21.m4 config/iconv.m4 config/intdiv0.m4 config/inttypes-pri.m4 config/inttypes.m4 config/inttypes_h.m4 config/lcmessage.m4 config/lib-ld.m4 config/lib-link.m4 config/lib-prefix.m4 config/mh-x86omitfp config/nls.m4 config/po.m4 config/stdint_h.m4 config/uintmax_t.m4 config/ulonglong.m4 config/warnings.m4 gdb/config/m32r/linux.mh gdb/config/m32r/linux.mt gdb/config/m32r/nm-linux.h gdb/fbsd-nat.c gdb/fbsd-nat.h gdb/i386bsd-nat.h gdb/m32r-linux-nat.c gdb/m32r-linux-tdep.c gdb/m32r-tdep.h gdb/testsuite/gdb.asm/m32r-linux.inc gdb/testsuite/gdb.dwarf2/Makefile.in gdb/testsuite/gdb.dwarf2/dw2-basic.S gdb/testsuite/gdb.dwarf2/dw2-basic.exp gdb/testsuite/gdb.dwarf2/dw2-intercu.S gdb/testsuite/gdb.dwarf2/dw2-intercu.exp gdb/testsuite/gdb.dwarf2/file1.txt gdb/testsuite/gdb.dwarf2/main.c gdb/testsuite/gdb.java/jprint.exp gdb/testsuite/gdb.java/jprint.java gdb/testsuite/gdb.threads/watchthreads.c
Diffstat (limited to 'intl/bindtextdom.c')
-rw-r--r--intl/bindtextdom.c203
1 files changed, 203 insertions, 0 deletions
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
new file mode 100644
index 0000000..d9c3f34
--- /dev/null
+++ b/intl/bindtextdom.c
@@ -0,0 +1,203 @@
+/* Implementation of the bindtextdomain(3) function
+ Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#else
+# ifdef HAVE_MALLOC_H
+# include <malloc.h>
+# else
+void free ();
+# endif
+#endif
+
+#if defined HAVE_STRING_H || defined _LIBC
+# include <string.h>
+#else
+# include <strings.h>
+# ifndef memcpy
+# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
+# endif
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "libgettext.h"
+#endif
+#include "gettext.h"
+#include "gettextP.h"
+
+/* @@ end of prolog @@ */
+
+/* Contains the default location of the message catalogs. */
+extern const char _nl_default_dirname[];
+
+/* List with bindings of specific domains. */
+extern struct binding *_nl_domain_bindings;
+
+
+/* Names for the libintl functions are a problem. They must not clash
+ with existing names and they should follow ANSI C. But this source
+ code is also used in GNU C Library where the names have a __
+ prefix. So we have to make a difference here. */
+#ifdef _LIBC
+# define BINDTEXTDOMAIN __bindtextdomain
+# ifndef strdup
+# define strdup(str) __strdup (str)
+# endif
+#else
+# define BINDTEXTDOMAIN bindtextdomain__
+#endif
+
+/* Specify that the DOMAINNAME message catalog will be found
+ in DIRNAME rather than in the system locale data base. */
+char *
+BINDTEXTDOMAIN (domainname, dirname)
+ const char *domainname;
+ const char *dirname;
+{
+ struct binding *binding;
+
+ /* Some sanity checks. */
+ if (domainname == NULL || domainname[0] == '\0')
+ return NULL;
+
+ for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
+ {
+ int compare = strcmp (domainname, binding->domainname);
+ if (compare == 0)
+ /* We found it! */
+ break;
+ if (compare < 0)
+ {
+ /* It is not in the list. */
+ binding = NULL;
+ break;
+ }
+ }
+
+ if (dirname == NULL)
+ /* The current binding has be to returned. */
+ return binding == NULL ? (char *) _nl_default_dirname : binding->dirname;
+
+ if (binding != NULL)
+ {
+ /* The domain is already bound. If the new value and the old
+ one are equal we simply do nothing. Otherwise replace the
+ old binding. */
+ if (strcmp (dirname, binding->dirname) != 0)
+ {
+ char *new_dirname;
+
+ if (strcmp (dirname, _nl_default_dirname) == 0)
+ new_dirname = (char *) _nl_default_dirname;
+ else
+ {
+#if defined _LIBC || defined HAVE_STRDUP
+ new_dirname = strdup (dirname);
+ if (new_dirname == NULL)
+ return NULL;
+#else
+ size_t len = strlen (dirname) + 1;
+ new_dirname = (char *) malloc (len);
+ if (new_dirname == NULL)
+ return NULL;
+
+ memcpy (new_dirname, dirname, len);
+#endif
+ }
+
+ if (binding->dirname != _nl_default_dirname)
+ free (binding->dirname);
+
+ binding->dirname = new_dirname;
+ }
+ }
+ else
+ {
+ /* We have to create a new binding. */
+#if !defined _LIBC && !defined HAVE_STRDUP
+ size_t len;
+#endif
+ struct binding *new_binding =
+ (struct binding *) malloc (sizeof (*new_binding));
+
+ if (new_binding == NULL)
+ return NULL;
+
+#if defined _LIBC || defined HAVE_STRDUP
+ new_binding->domainname = strdup (domainname);
+ if (new_binding->domainname == NULL)
+ return NULL;
+#else
+ len = strlen (domainname) + 1;
+ new_binding->domainname = (char *) malloc (len);
+ if (new_binding->domainname == NULL)
+ return NULL;
+ memcpy (new_binding->domainname, domainname, len);
+#endif
+
+ if (strcmp (dirname, _nl_default_dirname) == 0)
+ new_binding->dirname = (char *) _nl_default_dirname;
+ else
+ {
+#if defined _LIBC || defined HAVE_STRDUP
+ new_binding->dirname = strdup (dirname);
+ if (new_binding->dirname == NULL)
+ return NULL;
+#else
+ len = strlen (dirname) + 1;
+ new_binding->dirname = (char *) malloc (len);
+ if (new_binding->dirname == NULL)
+ return NULL;
+ memcpy (new_binding->dirname, dirname, len);
+#endif
+ }
+
+ /* Now enqueue it. */
+ if (_nl_domain_bindings == NULL
+ || strcmp (domainname, _nl_domain_bindings->domainname) < 0)
+ {
+ new_binding->next = _nl_domain_bindings;
+ _nl_domain_bindings = new_binding;
+ }
+ else
+ {
+ binding = _nl_domain_bindings;
+ while (binding->next != NULL
+ && strcmp (domainname, binding->next->domainname) > 0)
+ binding = binding->next;
+
+ new_binding->next = binding->next;
+ binding->next = new_binding;
+ }
+
+ binding = new_binding;
+ }
+
+ return binding->dirname;
+}
+
+#ifdef _LIBC
+/* Alias for function name in GNU C Library. */
+weak_alias (__bindtextdomain, bindtextdomain);
+#endif