John beckett wrote:

> Bram Moolenaar wrote:
> 
> > OK, so we do need to worry about this.
> > 
> > This patch to message.c, replacing the previous one, should do it.
> 
> I've tried the additional patch, and some brief testing worked well.
> 
> However, there is a compiler warning due to converting double to size_t. That 
> could
> be fixed with:
> 
> *** bram/message.c
> --- src/message.c
> ***************
> *** 4533,4541 ****
>                       l = 1;
>                       if (precision_specified)
>                       {
> !                         if (fmt_spec == 'f'
> !                                 && log10(f) + precision > TMP_LEN - 10)
> !                             precision = TMP_LEN - 10 - log10(f);
>                           else if (precision > TMP_LEN - 10)
>                               precision = TMP_LEN - 10;
>                           l += sprintf(format + 1, ".%d", precision);
> --- 4533,4541 ----
>                       l = 1;
>                       if (precision_specified)
>                       {
> !                         if (fmt_spec == 'f' &&
> !                                 (size_t)log10(f) + precision > TMP_LEN - 10)
> !                             precision = TMP_LEN - 10 - (size_t)log10(f);
>                           else if (precision > TMP_LEN - 10)
>                               precision = TMP_LEN - 10;
>                           l += sprintf(format + 1, ".%d", precision);
> 
> Due to rounding differences, the above can generate a precision that
> is 1 more than occurred in the original, but the '- 10' should take
> care of that.

Thanks.  I'll change it a big to avoid using log10() twice:

                        if (precision_specified)
                        {
                            size_t max_prec = TMP_LEN - 10;

                            if (fmt_spec == 'f' && f > 1.0)
                                max_prec -= (size_t)log10(f);
                            if (precision > max_prec)
                                precision = max_prec;
                            l += sprintf(format + 1, ".%d", precision);
                        }

-- 
   They now pass three KNIGHTS impaled to a tree.  With their feet off the
   ground,  with one lance through the lot of them, they are skewered up
   like a barbecue.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui