summary refs log tree commit diff
path: root/intl/dcgettext.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-08-22 22:39:16 +0000
committerUlrich Drepper <drepper@redhat.com>1999-08-22 22:39:16 +0000
commitc90a2db6e0c4661091a9c5b1454a9beffc611e9e (patch)
tree22fd71bef937c16b2468c25649c71b77940908a4 /intl/dcgettext.c
parent60c53a1219b9f0ee9c1787f2b160b362e7f94457 (diff)
downloadglibc-c90a2db6e0c4661091a9c5b1454a9beffc611e9e.tar.gz
glibc-c90a2db6e0c4661091a9c5b1454a9beffc611e9e.tar.xz
glibc-c90a2db6e0c4661091a9c5b1454a9beffc611e9e.zip
Update.
1999-08-22  Ulrich Drepper  <drepper@cygnus.com>

	* iconv/gconv_int.h (GCONV_AVOID_NOCONV): New definition.
	(__gconv_find_transform): Update prototype.
	(__gconv_open): Likewise.
	* iconv/gconv_open.c: Take extra parameter and pass it to
	__gconv_find_transform.
	* iconv/gconv_db.c (__gconv_find_transform): Take extra parameter with
	flags.  If GCONV_AVOID_NOCONV flag is set don't return copying
	transformation.
	* iconv/iconv_open.c: Pass extra parameter to __gconv_open.
	* wcsmbs/wcsmbsload.c: Likewise.
	* intl/dcgettext.c (_nl_find_msg): Rewrite to use gconv instead of
	iconv for glibc.
	* intl/gettextP.h: Likewise.
	* intl/loadmsgcat.c: Likewise.

	* posix/regexbug1.c: New file.
	* posix/Makefile (tests): Add regexbug1.
Diffstat (limited to 'intl/dcgettext.c')
-rw-r--r--intl/dcgettext.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/intl/dcgettext.c b/intl/dcgettext.c
index 0429cc904e..d482da39b8 100644
--- a/intl/dcgettext.c
+++ b/intl/dcgettext.c
@@ -479,8 +479,12 @@ _nl_find_msg (domain_file, msgid)
 				       domain->trans_tab[nstr - 1].offset);
 
 	  if (
-#if HAVE_ICONV || defined _LIBC
+#ifdef _LIBC
+	      domain->conv != (__gconv_t) -1
+#else
+# if HAVE_ICONV
 	      domain->conv != (iconv_t) -1
+# endif
 #endif
 	      )
 	    {
@@ -508,21 +512,23 @@ _nl_find_msg (domain_file, msgid)
 		     We allocate always larger blocks which get used over
 		     time.  This is faster than many small allocations.   */
 		  __libc_lock_define_initialized (static, lock)
-		  static char *freemem;
+		  static unsigned char *freemem;
 		  static size_t freemem_size;
 		  /* Note that we include the NUL byte.  */
 		  size_t resultlen = strlen (result) + 1;
-		  const char *inbuf = result;
-		  size_t inbytesleft = resultlen;
-		  char *outbuf = freemem;
-		  size_t outbytesleft = freemem_size;
+		  const unsigned char *inbuf = result;
+		  unsigned char *outbuf = freemem;
+		  size_t written;
+		  int res;
 
 		  __libc_lock_lock (lock);
 
-		  while (iconv (domain->conv, &inbuf, &inbytesleft, &outbuf,
-				&outbytesleft) == (size_t) -1L)
+		  while ((res = __gconv (domain->conv,
+					 &inbuf, inbuf + resultlen,
+					 &outbuf, outbuf + freemem_size,
+					 &written)) == __GCONV_OK)
 		    {
-		      if (errno != E2BIG)
+		      if (res != __GCONV_FULL_OUTPUT)
 			goto out;
 
 		      /* We must resize the buffer.  */
@@ -532,16 +538,14 @@ _nl_find_msg (domain_file, msgid)
 			goto out;
 
 		      inbuf = result;
-		      inbytesleft = resultlen;
 		      outbuf = freemem;
-		      outbytesleft = freemem_size;
 		    }
 
 		  /* We have now in our buffer a converted string.  Put this
 		     in the hash table  */
 		  domain->conv_tab[idx] = freemem;
+		  freemem_size -= outbuf - freemem;
 		  freemem = outbuf;
-		  freemem_size = outbytesleft;
 
 		out:
 		  __libc_lock_unlock (lock);