Ilya Bobir wrote:

> Bram Moolenaar wrote:
> > [...]
> >> The second was a proposal to represent floats as numbers with decimal
> >> points but no additional punctuation which was implicit in this report
> >> from Ilya Bobir:
> >>
> >> - I did a search for vim scripts that use concatenation operation
> >>    between two numbers without interleaving space.  It appears that
> >>    Google Code Search was able to find only 39 matches and all were
> >>    false positives.
> >>
> >> Nobody gave any reply to the message.
> >>     
> >
> > I wonder how you do that search.
>
> I've explained how I did the search in my email on that thread.  
> Probably you missed it, so I include this email here.  Here it goes:
> 
> Ilya Bobir wrote:
> > Bram Moolenaar wrote:
> >   
> >> [...]
> >>
> >> I would still like feedback on the format of floating point numbers:
> >>
> >>    &123.456
> >>    &1.23e-3
> >>   
> >>     
> >
> > I did a search for vim scripts that use concatenation operation between two
> > numbers without interleaving space.  It appears that Google Code Search was
> > able to find only 39 matches and all where false positives.
> > Here is the query:
> >
> > http://www.google.com/codesearch?hl=ru&q=+lang:vim+%5E%5Cs*%5B%5E%22%5C+%5D(%22(%5C%5C.%7C%5B%5E%22%5D)*%22%7C%27%5B%5E%27%5D*%27%7C%5B%5E%22%5D)*%5Cs%5Cd%2B%5C.%5Cd%2B%5Cs+-menu&start=30&sa=N
> >
> > And here is a regex I've used (along with explanations). Maybe someone will
> > double check to make sure I did not mistake.
> >
> > lang:vim                   | Vim script language.
> > ^\s*[^"\ ]                 | In order to exclude comments the line should
> >                            |   start with anything but ".
> > (                          | Catches different kind of strings.
> >     " ( \\. | [^"] )* "    | Double quoted strings along with escapes
> >                            |   inside the string.
> >     | ' [^']* '            | Single quoted strings.
> >     | [^"]                 | All the rest is OK.  And there maybe some
> >                            |   staff preceding the digits.
> > )*                         |
> > \s\d+\.\d+\s               | A pattern that I was looking for - two numbers
> >                            |   concatenated without an interleaving space
> >                            |   that are not part of a longer sequence.
> > -menu                      | menu command uses dot separated numbers to set
> >                            |   priority.  There are plenty of them and all
> >                            |   are false positives, so remove all lines with
> >                            |   "menu" string in them.
> >   
> 
> If something is hard to understand, please ask, I'll try to explain 
> another way.  English is not my native language and sometimes I really 
> have no clue whether what I write is understandable at all =)

It's not perfect and Google code search certainly doesn't contain every
Vim script, but it's an indication.

> >   And if you manage to come up with the
> > right pattern, what the number of matches actually means.
> 
> The number of matches is the number of lines that have two numbers 
> concatenated without interleaving spaces.  A real match would mean that 
> adding a "common" syntax for floats into Vim script would break a script 
> with the match.

I meant: Since Google code search contains only a subset of all the Vim
scripts, what does it mean not to find a text string there that looks
like a floating point number?  There might be one very important Vim
script that breaks that isn't in Google code search.

[...]

Anyway, here is a patch to accept plain floating point numbers.  Goes on
top of the previous floating point patch.  Give it a try and find out if
any of your scripts break.


*** ../vim-7.1.311/src/eval.c   Thu May 29 21:46:10 2008
--- src/eval.c  Wed Jun  4 22:41:20 2008
***************
*** 4600,4613 ****
      case '7':
      case '8':
      case '9':
!               vim_str2nr(*arg, NULL, &len, TRUE, TRUE, &n, NULL);
!               *arg += len;
!               if (evaluate)
                {
!                   rettv->v_type = VAR_NUMBER;
!                   rettv->vval.v_number = n;
                }
                break;
  
      /*
       * String constant: "string".
--- 4799,4847 ----
      case '7':
      case '8':
      case '9':
!       {
! #ifdef FEAT_FLOAT
!               char_u *p = skipdigits(*arg + 1);
!               int    get_float = FALSE;
! 
!               /* We accept a float when the format matches
!                * "[0-9]\+\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?".  This is very
!                * strict to avoid backwards compatibility problems. */
!               if (p[0] == '.' && vim_isdigit(p[1]))
!               {
!                   get_float = TRUE;
!                   p = skipdigits(p + 2);
!                   if (*p == 'e' || *p == 'E')
!                   {
!                       ++p;
!                       if (*p == '-' || *p == '+')
!                           ++p;
!                       if (!vim_isdigit(*p))
!                           get_float = FALSE;
!                       else
!                           p = skipdigits(p + 1);
!                   }
!                   if (ASCII_ISALPHA(*p) || *p == '.')
!                       get_float = FALSE;
!               }
!               if (get_float)
                {
!                   --*arg;  /* pretend there is a '&' TODO: remove */
!                   get_float_tv(arg, rettv, evaluate);
!               }
!               else
! #endif
!               {
!                   vim_str2nr(*arg, NULL, &len, TRUE, TRUE, &n, NULL);
!                   *arg += len;
!                   if (evaluate)
!                   {
!                       rettv->v_type = VAR_NUMBER;
!                       rettv->vval.v_number = n;
!                   }
                }
                break;
+       }
  
      /*
       * String constant: "string".

-- 
It's totally unfair to suggest - as many have - that engineers are socially
inept.  Engineers simply have different objectives when it comes to social
interaction.
                                (Scott Adams - The Dilbert principle)

 /// 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