Hi,

From: Daniel Burrows
Subject: Re: Bug#395007: aptitude --show-deps is broken for multibyte 
descriptive text
Date: Wed, 25 Oct 2006 17:08:26 -0700

> On Tue, Oct 24, 2006 at 08:16:31PM +0900, Kobayashi Noritada <[EMAIL 
> PROTECTED]> was heard to say:
> > Actually, following code at reason_string_list in 
> > src/cmdline/cmdline_prompt.cc
> > cannot handle multibyte characters:
> > 
> >   s+=const_cast<pkgCache::DepIterator &>(why->dep).DepType()[0];

>   It seems to me like this does the job:
> 
> diff -rN -u old-head/src/cmdline/cmdline_prompt.cc 
> new-head/src/cmdline/cmdline_prompt.cc
> --- old-head/src/cmdline/cmdline_prompt.cc    2006-10-25 16:54:54.000000000 
> -0700
> +++ new-head/src/cmdline/cmdline_prompt.cc    2006-10-25 16:54:54.000000000 
> -0700
> @@ -19,6 +19,7 @@
>  
>  #include <vscreen/fragment.h>
>  #include <vscreen/vscreen.h>
> +#include <vscreen/transcode.h>
>  
>  #include <apt-pkg/algorithms.h>
>  #include <apt-pkg/dpkgpm.h>
> @@ -83,7 +84,8 @@
>         first=false;
>       }
>  
> -      s+=const_cast<pkgCache::DepIterator &>(why->dep).DepType()[0];
> +      wstring dep_name = transcode(const_cast<pkgCache::DepIterator 
> &>(why->dep).DepType());
> +      s += transcode(dep_name.substr(0, 1));
>        s+=": ";
>        s+=why->pkg.Name();
>      }

I've rebuilt and checked that this fix works.

>   The main drawback is that it doesn't do error-checking, which means
> that a broken translation file will result in all the dependency types
> turning into "?".  This leads me to a broader question, though: is the
> first character really a suitable abbreviation for the dependency type
> in all languages?  I wonder, for instance, whether just the first
> Chinese character will be understood by Chinese speakers as a shortening
> of the dependency type string.  Probably I should eventually add a
> special set of "dependency abbreviation" translations, but right now
> Christian will kill me if I do that. ;-)

Yes, you are right.  Fortunately, at least for Japanese translation,
which uses Chinese characters as expressions of dependencies and is
completely different from English text, the first character of
dependency type is a valid abbreviation, but I can never say that the
situation is the same for all the languages.  This should be a quick
hack as you says.

> > -      s+=const_cast<pkgCache::DepIterator &>(why->dep).DepType()[0];
> > +      mbstate_t mbstate;
> > +      size_t len;
> > +      char *dep_type=strdup(const_cast<pkgCache::DepIterator 
> > &>(why->dep).DepType());
> > +      memset(&mbstate, 0, sizeof(mbstate));
> > +      len=mbrlen(dep_type, strlen(dep_type), &mbstate);
> > +      dep_type[len]=0;
> > +      s+=dep_type;

>   I assume this is pretty efficient, but it's also not consistent with
> the rest of the aptitude codebase (and I doubt that efficiency matters
> here).

Exactly I also bothered about the inconsistency of code for this patch...

>   I'd lean in favor of the simple approach as a short-term solution, and
> using a proper separate translation in the long term.

Thank you.  I agree with that policy.

Many thanks,

-nori


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to