Translated message "match %d of %d" is truncated.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Translated message "match %d of %d" is truncated.

Yukihiro Nakadaira-2
According to src/edit.c

4971  if (compl_curr_match->cp_number != -1)
4972  {
4973      /* Space for 10 text chars. + 2x10-digit no.s */
4974      static char_u match_ref[31];
4975
4976      if (compl_matches > 0)
4977          sprintf((char *)IObuff, _("match %d of %d"),
4978                      compl_curr_match->cp_number, compl_matches);
4979      else
4980          sprintf((char *)IObuff, _("match %d"),
4981                                       compl_curr_match->cp_number);
4982      vim_strncpy(match_ref, IObuff, 30);

This message "match %d of %d" is stored into the buffer named match_ref
which have bytes for 30 chars.  But 30 bytes is not enough to be used to
store the translated multibyte message.  In Japanese locale this message
is truncated.  Current Japanese message in ja.po requires 46 bytes (26
text bytes + 2x10-digit) in Japanese DBCS encoding and 56 bytes in utf-8
encoding.  Maybe 30 bytes is also not enough for other language.  Could
you increase the buffer size?

--
Yukihiro Nakadaira - [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Translated message "match %d of %d" is truncated.

Bram Moolenaar

Yukihiro Nakadaira wrote:

> According to src/edit.c
>
> 4971  if (compl_curr_match->cp_number != -1)
> 4972  {
> 4973      /* Space for 10 text chars. + 2x10-digit no.s */
> 4974      static char_u match_ref[31];
> 4975
> 4976      if (compl_matches > 0)
> 4977          sprintf((char *)IObuff, _("match %d of %d"),
> 4978                      compl_curr_match->cp_number, compl_matches);
> 4979      else
> 4980          sprintf((char *)IObuff, _("match %d"),
> 4981                                       compl_curr_match->cp_number);
> 4982      vim_strncpy(match_ref, IObuff, 30);
>
> This message "match %d of %d" is stored into the buffer named match_ref
> which have bytes for 30 chars.  But 30 bytes is not enough to be used to
> store the translated multibyte message.  In Japanese locale this message
> is truncated.  Current Japanese message in ja.po requires 46 bytes (26
> text bytes + 2x10-digit) in Japanese DBCS encoding and 56 bytes in utf-8
> encoding.  Maybe 30 bytes is also not enough for other language.  Could
> you increase the buffer size?

Yes, the size is too small for translated messages.  Also, we can now
use vim_snprintf() instead of using IObuff.  Please try this patch:

*** ../vim-7.0.188/src/edit.c Wed Nov  1 21:24:58 2006
--- src/edit.c Fri Jan 19 20:22:09 2007
***************
*** 4970,4985 ****
      * just a safety check. */
     if (compl_curr_match->cp_number != -1)
     {
! /* Space for 10 text chars. + 2x10-digit no.s */
! static char_u match_ref[31];
 
  if (compl_matches > 0)
!    sprintf((char *)IObuff, _("match %d of %d"),
  compl_curr_match->cp_number, compl_matches);
  else
!    sprintf((char *)IObuff, _("match %d"),
! compl_curr_match->cp_number);
! vim_strncpy(match_ref, IObuff, 30);
  edit_submode_extra = match_ref;
  edit_submode_highl = HLF_R;
  if (dollar_vcol)
--- 4970,4987 ----
      * just a safety check. */
     if (compl_curr_match->cp_number != -1)
     {
! /* Space for 10 text chars. + 2x10-digit no.s = 31.
! * Translations may need more than twice that. */
! static char_u match_ref[81];
 
  if (compl_matches > 0)
!    vim_snprintf((char *)match_ref, sizeof(match_ref),
! _("match %d of %d"),
  compl_curr_match->cp_number, compl_matches);
  else
!    vim_snprintf((char *)match_ref, sizeof(match_ref),
! _("match %d"),
! compl_curr_match->cp_number);
  edit_submode_extra = match_ref;
  edit_submode_highl = HLF_R;
  if (dollar_vcol)


--
Nothing is fool-proof to a sufficiently talented fool.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
Reply | Threaded
Open this post in threaded view
|

Re: Translated message "match %d of %d" is truncated.

Yukihiro Nakadaira-2
Bram Moolenaar wrote:
> Yes, the size is too small for translated messages.  Also, we can now
> use vim_snprintf() instead of using IObuff.  Please try this patch:

I tried that patch and it worked.  Thank you.

--
Yukihiro Nakadaira - [hidden email]