mirror of git://sourceware.org/git/glibc.git
Update.
* localedata/Makefile (tests): Add bug-iconv-trans. Define bug-iconv-trans-ENV. * localedata/bug-iconv-trans.c: New file. 2001-02-04 Bruno Haible <haible@clisp.cons.org> * iconv/gconv_trans.c (__gconv_transliterate): Use a temporary output pointer, to avoid accumulating output from incomplete (unsuccessful) transliteration attempts. 2001-02-05 Ulrich Drepper <drepper@redhat.com>
This commit is contained in:
parent
5a35dfca75
commit
403cb8a19c
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2001-02-05 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* localedata/Makefile (tests): Add bug-iconv-trans.
|
||||||
|
Define bug-iconv-trans-ENV.
|
||||||
|
* localedata/bug-iconv-trans.c: New file.
|
||||||
|
|
||||||
|
2001-02-04 Bruno Haible <haible@clisp.cons.org>
|
||||||
|
|
||||||
|
* iconv/gconv_trans.c (__gconv_transliterate): Use a temporary output
|
||||||
|
pointer, to avoid accumulating output from incomplete (unsuccessful)
|
||||||
|
transliteration attempts.
|
||||||
|
|
||||||
2001-02-05 Ulrich Drepper <drepper@redhat.com>
|
2001-02-05 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* elf/ldconfig.c (search_dir): Use PRIx64 instead of Lx in printf
|
* elf/ldconfig.c (search_dir): Use PRIx64 instead of Lx in printf
|
||||||
|
|
|
@ -111,17 +111,18 @@ __gconv_transliterate (struct __gconv_step *step,
|
||||||
uint_fast32_t len = 0;
|
uint_fast32_t len = 0;
|
||||||
int res;
|
int res;
|
||||||
const unsigned char *toinptr;
|
const unsigned char *toinptr;
|
||||||
|
unsigned char *outptr;
|
||||||
|
|
||||||
while (to_tbl[idx2 + len] != L'\0')
|
while (to_tbl[idx2 + len] != L'\0')
|
||||||
++len;
|
++len;
|
||||||
|
|
||||||
/* Try this input text. */
|
/* Try this input text. */
|
||||||
toinptr = (const unsigned char *) &to_tbl[idx2];
|
toinptr = (const unsigned char *) &to_tbl[idx2];
|
||||||
|
outptr = *outbufstart;
|
||||||
res = DL_CALL_FCT (step->__fct,
|
res = DL_CALL_FCT (step->__fct,
|
||||||
(step, step_data, &toinptr,
|
(step, step_data, &toinptr,
|
||||||
(const unsigned char *) &to_tbl[idx2 + len],
|
(const unsigned char *) &to_tbl[idx2 + len],
|
||||||
(unsigned char **) outbufstart,
|
&outptr, NULL, 0, 0));
|
||||||
NULL, 0, 0));
|
|
||||||
if (res != __GCONV_ILLEGAL_INPUT)
|
if (res != __GCONV_ILLEGAL_INPUT)
|
||||||
{
|
{
|
||||||
/* If the conversion succeeds we have to increment the
|
/* If the conversion succeeds we have to increment the
|
||||||
|
@ -132,6 +133,7 @@ __gconv_transliterate (struct __gconv_step *step,
|
||||||
++*irreversible;
|
++*irreversible;
|
||||||
res = __GCONV_OK;
|
res = __GCONV_OK;
|
||||||
}
|
}
|
||||||
|
*outbufstart = outptr;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +195,7 @@ __gconv_transliterate (struct __gconv_step *step,
|
||||||
const unsigned char *toinptr = (const unsigned char *) default_missing;
|
const unsigned char *toinptr = (const unsigned char *) default_missing;
|
||||||
uint32_t len = _NL_CURRENT_WORD (LC_CTYPE,
|
uint32_t len = _NL_CURRENT_WORD (LC_CTYPE,
|
||||||
_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN);
|
_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN);
|
||||||
|
unsigned char *outptr;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
/* Test whether there is enough input. */
|
/* Test whether there is enough input. */
|
||||||
|
@ -200,11 +203,11 @@ __gconv_transliterate (struct __gconv_step *step,
|
||||||
return (winbuf == winbufend
|
return (winbuf == winbufend
|
||||||
? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT);
|
? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT);
|
||||||
|
|
||||||
|
outptr = *outbufstart;
|
||||||
res = DL_CALL_FCT (step->__fct,
|
res = DL_CALL_FCT (step->__fct,
|
||||||
(step, step_data, &toinptr,
|
(step, step_data, &toinptr,
|
||||||
(const unsigned char *) (default_missing + len),
|
(const unsigned char *) (default_missing + len),
|
||||||
(unsigned char **) outbufstart,
|
&outptr, NULL, 0, 0));
|
||||||
NULL, 0, 0));
|
|
||||||
|
|
||||||
if (res != __GCONV_ILLEGAL_INPUT)
|
if (res != __GCONV_ILLEGAL_INPUT)
|
||||||
{
|
{
|
||||||
|
@ -217,6 +220,7 @@ __gconv_transliterate (struct __gconv_step *step,
|
||||||
*inbufp += 4;
|
*inbufp += 4;
|
||||||
res = __GCONV_OK;
|
res = __GCONV_OK;
|
||||||
}
|
}
|
||||||
|
*outbufstart = outptr;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \
|
||||||
tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \
|
tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \
|
||||||
tst_wctype tst_wcwidth
|
tst_wctype tst_wcwidth
|
||||||
|
|
||||||
tests = $(locale_test_suite) tst-digits tst-setlocale
|
tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Files to install.
|
# Files to install.
|
||||||
|
@ -256,3 +256,5 @@ tst_wcwidth-ENV = $(TEST_MBWC_ENV)
|
||||||
tst-digits-ENV = $(TEST_MBWC_ENV)
|
tst-digits-ENV = $(TEST_MBWC_ENV)
|
||||||
|
|
||||||
tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP
|
tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP
|
||||||
|
|
||||||
|
bug-iconv-trans-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#include <iconv.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
iconv_t cd;
|
||||||
|
const char str[] = "ÄäÖöÜüß";
|
||||||
|
const char expected[] = "AEaeOEoeUEuess";
|
||||||
|
char *inptr = (char *) str;
|
||||||
|
size_t inlen = strlen (str) + 1;
|
||||||
|
char outbuf[500];
|
||||||
|
char *outptr = outbuf;
|
||||||
|
size_t outlen = sizeof (outbuf);
|
||||||
|
int result = 0;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
|
||||||
|
{
|
||||||
|
puts ("setlocale failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cd = iconv_open ("ANSI_X3.4-1968//TRANSLIT", "ISO-8859-1");
|
||||||
|
if (cd == (iconv_t) -1)
|
||||||
|
{
|
||||||
|
puts ("iconv_open failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
|
||||||
|
if (n != 7)
|
||||||
|
{
|
||||||
|
printf ("iconv() returned %Zd, expected 7\n", n);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
if (inlen != 0)
|
||||||
|
{
|
||||||
|
puts ("not all input consumed");
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
else if (inptr - str != strlen (str) + 1)
|
||||||
|
{
|
||||||
|
printf ("inptr wrong, advanced by %td\n", inptr - str);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
if (memcmp (outbuf, expected, sizeof (expected)) != 0)
|
||||||
|
{
|
||||||
|
printf ("result wrong: \"%.*s\", expected: \"%s\"\n",
|
||||||
|
(int) (sizeof (outbuf) - outlen), outbuf, expected);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
else if (outlen != sizeof (outbuf) - sizeof (expected))
|
||||||
|
{
|
||||||
|
printf ("outlen wrong: %Zd, expected %Zd\n", outlen,
|
||||||
|
sizeof (outbuf) - 15);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf ("output is \"%s\" which is OK\n", outbuf);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -221,8 +221,13 @@ The symbols in this section are defined in the header file @file{locale.h}.
|
||||||
@comment locale.h
|
@comment locale.h
|
||||||
@comment ISO
|
@comment ISO
|
||||||
@deftypefun {char *} setlocale (int @var{category}, const char *@var{locale})
|
@deftypefun {char *} setlocale (int @var{category}, const char *@var{locale})
|
||||||
The function @code{setlocale} sets the current locale for
|
The function @code{setlocale} sets the current locale for category
|
||||||
category @var{category} to @var{locale}.
|
@var{category} to @var{locale}. A list of all the locales the system
|
||||||
|
provides can be created by running
|
||||||
|
|
||||||
|
@smallexample
|
||||||
|
locale -a
|
||||||
|
@end smallexample
|
||||||
|
|
||||||
If @var{category} is @code{LC_ALL}, this specifies the locale for all
|
If @var{category} is @code{LC_ALL}, this specifies the locale for all
|
||||||
purposes. The other possible values of @var{category} specify an
|
purposes. The other possible values of @var{category} specify an
|
||||||
|
@ -239,9 +244,11 @@ Concatenation}) if you want to save it past any further calls to
|
||||||
@code{setlocale}. (The standard library is guaranteed never to call
|
@code{setlocale}. (The standard library is guaranteed never to call
|
||||||
@code{setlocale} itself.)
|
@code{setlocale} itself.)
|
||||||
|
|
||||||
You should not modify the string returned by @code{setlocale}.
|
You should not modify the string returned by @code{setlocale}. It might
|
||||||
It might be the same string that was passed as an argument in a
|
be the same string that was passed as an argument in a previous call to
|
||||||
previous call to @code{setlocale}.
|
@code{setlocale}. One requirement is that the @var{category} must be
|
||||||
|
the same in the call the string was returned and the one when the string
|
||||||
|
is passed in as @var{locale} parameter.
|
||||||
|
|
||||||
When you read the current locale for category @code{LC_ALL}, the value
|
When you read the current locale for category @code{LC_ALL}, the value
|
||||||
encodes the entire combination of selected locales for all categories.
|
encodes the entire combination of selected locales for all categories.
|
||||||
|
|
Loading…
Reference in New Issue