summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e29f5ae)
- fix malloc asseration fail with ja_JP.eucJP locale in
apt-cache search. Thanks Kusanagi Kouichi! (Closes: #548884)
{
iconv_t cd;
const char *inbuf;
{
iconv_t cd;
const char *inbuf;
- char *inptr, *outbuf, *outptr;
- size_t insize, outsize;
-
+ char *inptr, *outbuf;
+ size_t insize, bufsize;
+ dest->clear();
+
cd = iconv_open(codeset, "UTF-8");
if (cd == (iconv_t)(-1)) {
// Something went wrong
cd = iconv_open(codeset, "UTF-8");
if (cd == (iconv_t)(-1)) {
// Something went wrong
else
perror("iconv_open");
else
perror("iconv_open");
- // Clean the destination string
- *dest = "";
-
- insize = outsize = orig.size();
+ insize = bufsize = orig.size();
inbuf = orig.data();
inptr = (char *)inbuf;
inbuf = orig.data();
inptr = (char *)inbuf;
- outbuf = new char[insize+1];
- outptr = outbuf;
+ outbuf = new char[bufsize];
+ size_t lastError = -1;
+ char *outptr = outbuf;
+ size_t outsize = bufsize;
size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize);
size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize);
+ dest->append(outbuf, outptr - outbuf);
if (err == (size_t)(-1))
{
if (err == (size_t)(-1))
{
- insize--;
- outsize++;
- inptr++;
- *outptr = '?';
- outptr++;
+ switch (errno)
+ {
+ case EILSEQ:
+ insize--;
+ inptr++;
+ // replace a series of unknown multibytes with a single "?"
+ if (lastError != insize) {
+ lastError = insize - 1;
+ dest->append("?");
+ }
+ break;
+ case EINVAL:
+ insize = 0;
+ break;
+ case E2BIG:
+ if (outptr == outbuf)
+ {
+ bufsize *= 2;
+ delete[] outbuf;
+ outbuf = new char[bufsize];
+ }
+ break;
+ }
- *outptr = '\0';
- *dest = outbuf;
delete[] outbuf;
iconv_close(cd);
delete[] outbuf;
iconv_close(cd);
- replace the per language addendum with a global addendum
- add a explanation why translations include (maybe) english
parts to the new global addendum (Closes: #561636)
- replace the per language addendum with a global addendum
- add a explanation why translations include (maybe) english
parts to the new global addendum (Closes: #561636)
+ * apt-pkg/contrib/strutl.cc:
+ - fix malloc asseration fail with ja_JP.eucJP locale in
+ apt-cache search. Thanks Kusanagi Kouichi! (Closes: #548884)
-- David Kalnischkies <kalnischkies@gmail.com> Sat, 16 Jan 2010 21:06:38 +0100
-- David Kalnischkies <kalnischkies@gmail.com> Sat, 16 Jan 2010 21:06:38 +0100