From: Bruno Haible Date: Mon, 9 May 2005 19:16:55 +0000 (+0000) Subject: glibc 2003-06-11 Ulrich Drepper X-Git-Tag: v0.15~528 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43733a0da83b25554b5a091088abd3006a7cd877;p=thirdparty%2Fgettext.git glibc 2003-06-11 Ulrich Drepper Move the hash_string function to a separate file hash-string.c --- diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index 5c3487e5e..a5a6b8cb3 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,24 @@ +2005-05-05 Bruno Haible + + * hash-string.h (__hash_string): Define differently outside glibc. + * hash-string.c: Include config.h. + * Makefile.in (SOURCES): Add hash-string.c. + (OBJECTS): Add hash-string.$lo. + (hash-string.lo): New rule. + (hash-string.$lo): Depend on hash-string.h. + * Makefile.msvc (OBJECTS): Add hash-string.obj. + (hash-string.obj): New rule. + * Makefile.vms (OBJECTS): Add hash-string.obj. + (hash-string.obj): New rule. + +2003-06-11 Ulrich Drepper + + Remove warnings gcc 3.3 shows. + * hash-string.c: New file. + * hash-string.h: Remove hash_string definition. Declare __hash_string. + * dcigettext.c (_nl_find_msg): Adjust hash_string caller. + * loadmsgcat.c (_nl_load_domain): Likewise. + 2003-04-29 Jakub Jelinek * plural.y: Include string.h. Needed because recent versions of bison diff --git a/gettext-runtime/intl/Makefile.in b/gettext-runtime/intl/Makefile.in index 1820f5374..5179258aa 100644 --- a/gettext-runtime/intl/Makefile.in +++ b/gettext-runtime/intl/Makefile.in @@ -85,6 +85,7 @@ SOURCES = \ dgettext.c \ gettext.c \ finddomain.c \ + hash-string.c \ loadmsgcat.c \ localealias.c \ textdomain.c \ @@ -111,6 +112,7 @@ OBJECTS = \ dgettext.$lo \ gettext.$lo \ finddomain.$lo \ + hash-string.$lo \ loadmsgcat.$lo \ localealias.$lo \ textdomain.$lo \ @@ -188,6 +190,8 @@ gettext.lo: $(srcdir)/gettext.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/gettext.c finddomain.lo: $(srcdir)/finddomain.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/finddomain.c +hash-string.lo: $(srcdir)/hash-string.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/hash-string.c loadmsgcat.lo: $(srcdir)/loadmsgcat.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/loadmsgcat.c localealias.lo: $(srcdir)/localealias.c @@ -426,7 +430,7 @@ info dvi ps pdf html: $(OBJECTS): ../config.h libgnuintl.h bindtextdom.$lo dcgettext.$lo dcigettext.$lo dcngettext.$lo dgettext.$lo dngettext.$lo finddomain.$lo gettext.$lo intl-compat.$lo loadmsgcat.$lo localealias.$lo ngettext.$lo textdomain.$lo: $(srcdir)/gettextP.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h -dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h +hash-string.$lo dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h explodename.$lo l10nflist.$lo: $(srcdir)/loadinfo.h dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: $(srcdir)/plural-exp.h dcigettext.$lo: $(srcdir)/eval-plural.h diff --git a/gettext-runtime/intl/Makefile.msvc b/gettext-runtime/intl/Makefile.msvc index 038321ee2..c48e1d9ee 100644 --- a/gettext-runtime/intl/Makefile.msvc +++ b/gettext-runtime/intl/Makefile.msvc @@ -99,7 +99,7 @@ INSTALL_DATA = copy SHELL = /bin/sh -OBJECTS = bindtextdom.obj dcgettext.obj dgettext.obj gettext.obj finddomain.obj loadmsgcat.obj localealias.obj textdomain.obj l10nflist.obj explodename.obj dcigettext.obj dcngettext.obj dngettext.obj ngettext.obj plural.obj plural-exp.obj localcharset.obj relocatable.obj langprefs.obj localename.obj log.obj printf.obj osdep.obj intl-compat.obj +OBJECTS = bindtextdom.obj dcgettext.obj dgettext.obj gettext.obj finddomain.obj hash-string.obj loadmsgcat.obj localealias.obj textdomain.obj l10nflist.obj explodename.obj dcigettext.obj dcngettext.obj dngettext.obj ngettext.obj plural.obj plural-exp.obj localcharset.obj relocatable.obj langprefs.obj localename.obj log.obj printf.obj osdep.obj intl-compat.obj RESOURCES = intl.res @@ -127,6 +127,9 @@ gettext.obj : $(srcdir)\gettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gm finddomain.obj : $(srcdir)\finddomain.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\finddomain.c +hash-string.obj : $(srcdir)\hash-string.c $(srcdir)\hash-string.h + $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\hash-string.c + loadmsgcat.obj : $(srcdir)\loadmsgcat.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h $(srcdir)\hash-string.h $(srcdir)\plural-exp.h $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\loadmsgcat.c diff --git a/gettext-runtime/intl/Makefile.vms b/gettext-runtime/intl/Makefile.vms index aa5be49d8..65d814d85 100644 --- a/gettext-runtime/intl/Makefile.vms +++ b/gettext-runtime/intl/Makefile.vms @@ -45,7 +45,7 @@ INSTALL_DATA = copy #### End of system configuration section. #### -OBJECTS = bindtextdom.obj,dcgettext.obj,dgettext.obj,gettext.obj,finddomain.obj,loadmsgcat.obj,localealias.obj,textdomain.obj,l10nflist.obj,explodename.obj,dcigettext.obj,dcngettext.obj,dngettext.obj,ngettext.obj,plural-parse.obj,plural-exp.obj,localcharset.obj,relocatable.obj,langprefs.obj,localename.obj,log.obj,osdep.obj,intl-compat.obj +OBJECTS = bindtextdom.obj,dcgettext.obj,dgettext.obj,gettext.obj,finddomain.obj,hash-string.obj,loadmsgcat.obj,localealias.obj,textdomain.obj,l10nflist.obj,explodename.obj,dcigettext.obj,dcngettext.obj,dngettext.obj,ngettext.obj,plural-parse.obj,plural-exp.obj,localcharset.obj,relocatable.obj,langprefs.obj,localename.obj,log.obj,osdep.obj,intl-compat.obj all : intl.olb,libintl.h write sys$output "Nothing else to be done for 'all'." @@ -68,6 +68,9 @@ gettext.obj : $(srcdir)gettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h finddomain.obj : $(srcdir)finddomain.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)finddomain.c +hash-string.obj : $(srcdir)hash-string.c,$(srcdir)hash-string.h + $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)hash-string.c + loadmsgcat.obj : $(srcdir)loadmsgcat.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h,$(srcdir)hash-string.h,$(srcdir)plural-exp.h $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)loadmsgcat.c diff --git a/gettext-runtime/intl/dcigettext.c b/gettext-runtime/intl/dcigettext.c index 8cb5ec88d..a5d986592 100644 --- a/gettext-runtime/intl/dcigettext.c +++ b/gettext-runtime/intl/dcigettext.c @@ -809,7 +809,7 @@ _nl_find_msg (struct loaded_l10nfile *domain_file, { /* Use the hashing table. */ nls_uint32 len = strlen (msgid); - nls_uint32 hash_val = hash_string (msgid); + nls_uint32 hash_val = __hash_string (msgid); nls_uint32 idx = hash_val % domain->hash_size; nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); diff --git a/gettext-runtime/intl/hash-string.c b/gettext-runtime/intl/hash-string.c new file mode 100644 index 000000000..311ff1087 --- /dev/null +++ b/gettext-runtime/intl/hash-string.c @@ -0,0 +1,51 @@ +/* Implements a string hashing function. + Copyright (C) 1995, 1997, 1998, 2000, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#include "hash-string.h" + + +/* Defines the so called `hashpjw' function by P.J. Weinberger + [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, + 1986, 1987 Bell Telephone Laboratories, Inc.] */ +unsigned long int +__hash_string (const char *str_param) +{ + unsigned long int hval, g; + const char *str = str_param; + + /* Compute the hash value for the given string. */ + hval = 0; + while (*str != '\0') + { + hval <<= 4; + hval += (unsigned char) *str++; + g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4)); + if (g != 0) + { + hval ^= g >> (HASHWORDBITS - 8); + hval ^= g; + } + } + return hval; +} diff --git a/gettext-runtime/intl/hash-string.h b/gettext-runtime/intl/hash-string.h index 093e3b1c1..3c52fce13 100644 --- a/gettext-runtime/intl/hash-string.h +++ b/gettext-runtime/intl/hash-string.h @@ -1,5 +1,5 @@ /* Description of GNU message catalog format: string hashing function. - Copyright (C) 1995, 1997-1998, 2000-2003 Free Software Foundation, Inc. + Copyright (C) 1995, 1997-1998, 2000-2003, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -22,27 +22,15 @@ #define HASHWORDBITS 32 +#ifndef _LIBC +# ifdef IN_LIBINTL +# define __hash_string libintl_hash_string +# else +# define __hash_string hash_string +# endif +#endif + /* Defines the so called `hashpjw' function by P.J. Weinberger [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, 1986, 1987 Bell Telephone Laboratories, Inc.] */ -static inline unsigned long int -hash_string (const char *str_param) -{ - unsigned long int hval, g; - const char *str = str_param; - - /* Compute the hash value for the given string. */ - hval = 0; - while (*str != '\0') - { - hval <<= 4; - hval += (unsigned char) *str++; - g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4)); - if (g != 0) - { - hval ^= g >> (HASHWORDBITS - 8); - hval ^= g; - } - } - return hval; -} +extern unsigned long int __hash_string (const char *str_param); diff --git a/gettext-runtime/intl/loadmsgcat.c b/gettext-runtime/intl/loadmsgcat.c index e708e20c7..30c4e011c 100644 --- a/gettext-runtime/intl/loadmsgcat.c +++ b/gettext-runtime/intl/loadmsgcat.c @@ -1184,7 +1184,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, for (i = 0; i < n_inmem_sysdep_strings; i++) { const char *msgid = inmem_orig_sysdep_tab[i].pointer; - nls_uint32 hash_val = hash_string (msgid); + nls_uint32 hash_val = __hash_string (msgid); nls_uint32 idx = hash_val % domain->hash_size; nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 9b3c88191..66c399883 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2005-05-05 Bruno Haible + + * Makefile.am (msgfmt_SOURCES): Add hash-string.c. + * Makefile.msvc (msgfmt_OBJECTS): Add hash-string.obj. + (hash-string.obj): New rule. + * Makefile.vms (msgfmt_OBJECTS): Add hash-string.obj. + (hash-string.obj): New rule. + 2005-05-01 Bruno Haible * x-sh.c (open_singlequote_terminator): New variable. diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index b61968dc5..370010e13 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -133,7 +133,7 @@ LIBUNINAME = ../libuniname/libuniname.a msgcmp_SOURCES = msgcmp.c msgfmt_SOURCES = msgfmt.c \ write-mo.c write-java.c write-csharp.c write-resources.c write-tcl.c \ - write-qt.c plural-eval.c + write-qt.c plural-eval.c ../../gettext-runtime/intl/hash-string.c msgmerge_SOURCES = msgmerge.c plural-count.c msgunfmt_SOURCES = msgunfmt.c \ read-mo.c read-java.c read-csharp.c read-resources.c read-tcl.c diff --git a/gettext-tools/src/Makefile.msvc b/gettext-tools/src/Makefile.msvc index 1a21328ed..599260656 100644 --- a/gettext-tools/src/Makefile.msvc +++ b/gettext-tools/src/Makefile.msvc @@ -151,7 +151,7 @@ OBJECTS = \ format-qt.obj msgcmp_OBJECTS = msgcmp.obj -msgfmt_OBJECTS = msgfmt.obj write-mo.obj write-java.obj write-csharp.obj write-resources.obj write-tcl.obj write-qt.obj plural-eval.obj +msgfmt_OBJECTS = msgfmt.obj write-mo.obj write-java.obj write-csharp.obj write-resources.obj write-tcl.obj write-qt.obj plural-eval.obj hash-string.obj msgmerge_OBJECTS = msgmerge.obj plural-count.obj msgunfmt_OBJECTS = msgunfmt.obj read-mo.obj read-java.obj read-csharp.obj read-resources.obj read-tcl.obj xgettext_OBJECTS = xgettext.obj x-c.obj x-po.obj x-sh.obj x-python.obj x-lisp.obj x-elisp.obj x-librep.obj x-scheme.obj x-smalltalk.obj x-java.obj x-csharp.obj x-awk.obj x-ycp.obj x-tcl.obj x-perl.obj x-php.obj x-rst.obj x-glade.obj @@ -351,6 +351,9 @@ write-qt.obj : write-qt.c plural-eval.obj : plural-eval.c $(CC) $(INCLUDES) $(CFLAGS) -c plural-eval.c +hash-string.obj : ..\..\gettext-runtime\intl\hash-string.c + $(CC) $(INCLUDES) $(CFLAGS) -c ..\..\gettext-runtime\intl\hash-string.c + msgmerge.obj : msgmerge.c $(CC) $(INCLUDES) $(CFLAGS) -DINSTALLPREFIX=\"$(IIprefix)\" -DINSTALLDIR=\"$(IIbindir)\" -c -Tp msgmerge.c diff --git a/gettext-tools/src/Makefile.vms b/gettext-tools/src/Makefile.vms index 9b53a4d2d..2d3766c56 100644 --- a/gettext-tools/src/Makefile.vms +++ b/gettext-tools/src/Makefile.vms @@ -97,7 +97,7 @@ OBJECTS = \ format-qt.obj msgcmp_OBJECTS = msgcmp.obj -msgfmt_OBJECTS = msgfmt.obj, write-mo.obj, write-java.obj, write-csharp.obj, write-resources.obj, write-tcl.obj, write-qt.obj, plural-eval.obj +msgfmt_OBJECTS = msgfmt.obj, write-mo.obj, write-java.obj, write-csharp.obj, write-resources.obj, write-tcl.obj, write-qt.obj, plural-eval.obj, hash-string.obj msgmerge_OBJECTS = msgmerge.obj, plural-count.obj msgunfmt_OBJECTS = msgunfmt.obj, read-mo.obj, read-java.obj, read-csharp.obj, read-resources.obj, read-tcl.obj xgettext_OBJECTS = xgettext.obj, x-c.obj, x-po.obj, x-sh.obj, x-python.obj, x-lisp.obj, x-elisp.obj, x-librep.obj, x-scheme.obj, x-smalltalk.obj, x-java.obj, x-csharp.obj, x-awk.obj, x-ycp.obj, x-tcl.obj, x-perl.obj, x-php.obj, x-rst.obj, x-glade.obj @@ -281,6 +281,9 @@ write-qt.obj : write-qt.c plural-eval.obj : plural-eval.c $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) plural-eval.c +hash-string.obj : [-.-.gettext-runtime.intl]hash-string.c + $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) [-.-.gettext-runtime.intl]hash-string.c + msgmerge.obj : msgmerge.c $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS),"INSTALLPREFIX=""$(prefix)]""","INSTALLDIR=""$(bindir)]""") msgmerge.c