Patch 8.0.1207
Problem:    Profiling skips the first and last script line.
Solution:   Check for BOM after setting script ID. (Lemonboy, closes #2103,
            closes #2112) Add a test. List the trailing script lines.
Files:      src/testdir/test_profile.vim, src/ex_cmds2.c


*** ../vim-8.0.1206/src/testdir/test_profile.vim        2017-08-14 
23:13:26.054283184 +0200
--- src/testdir/test_profile.vim        2017-10-19 20:59:24.124023627 +0200
***************
*** 115,121 ****
    call assert_match('^ Self time:\s\+\d\+\.\d\+$',                    
lines[3])
    call assert_equal('',                                               
lines[4])
    call assert_equal('count  total (s)   self (s)',                    
lines[5])
!   call assert_equal('                            func! Foo()',        
lines[6])
    call assert_equal('                            endfunc',            
lines[7])
    " Loop iterates 10 times. Since script runs twice, body executes 20 times.
    " First line of loop executes one more time than body to detect end of loop.
--- 115,121 ----
    call assert_match('^ Self time:\s\+\d\+\.\d\+$',                    
lines[3])
    call assert_equal('',                                               
lines[4])
    call assert_equal('count  total (s)   self (s)',                    
lines[5])
!   call assert_match('    2              0.\d\+ func! Foo()',          
lines[6])
    call assert_equal('                            endfunc',            
lines[7])
    " Loop iterates 10 times. Since script runs twice, body executes 20 times.
    " First line of loop executes one more time than body to detect end of loop.
***************
*** 130,135 ****
--- 130,171 ----
  
    call delete('Xprofile_file.vim')
    call delete('Xprofile_file.log')
+ endfunc
+ 
+ func Test_profile_file_with_cont()
+   let lines = [
+     \ 'echo "hello',
+     \ '  \ world"',
+     \ 'echo "foo ',
+     \ '  \bar"',
+     \ ]
+ 
+   call writefile(lines, 'Xprofile_file.vim')
+   call system(v:progpath
+     \ . ' -es --clean'
+     \ . ' -c "profile start Xprofile_file.log"'
+     \ . ' -c "profile file Xprofile_file.vim"'
+     \ . ' -c "so Xprofile_file.vim"'
+     \ . ' -c "qall!"')
+   call assert_equal(0, v:shell_error)
+ 
+   let lines = readfile('Xprofile_file.log')
+   call assert_equal(11, len(lines))
+ 
+   call assert_match('^SCRIPT .*Xprofile_file.vim$',                   
lines[0])
+   call assert_equal('Sourced 1 time',                                lines[1])
+   call assert_match('^Total time:\s\+\d\+\.\d\+$',                    
lines[2])
+   call assert_match('^ Self time:\s\+\d\+\.\d\+$',                    
lines[3])
+   call assert_equal('',                                               
lines[4])
+   call assert_equal('count  total (s)   self (s)',                    
lines[5])
+   call assert_match('    1              0.\d\+ echo "hello',          
lines[6])
+   call assert_equal('                              \ world"',         
lines[7])
+   call assert_match('    1              0.\d\+ echo "foo ',           
lines[8])
+   call assert_equal('                              \bar"',            
lines[9])
+   call assert_equal('',                                               
lines[10])
+ 
+   call delete('Xprofile_file.vim')
+   call delete('Xprofile_file.log')
  endfunc
  
  func Test_profile_completion()
*** ../vim-8.0.1206/src/ex_cmds2.c      2017-09-18 21:50:42.720750714 +0200
--- src/ex_cmds2.c      2017-10-19 21:04:15.122012696 +0200
***************
*** 1714,1720 ****
  }
  
  /*
!  * save time when starting to invoke another script or function.
   */
      void
  script_prof_save(
--- 1714,1720 ----
  }
  
  /*
!  * Save time when starting to invoke another script or function.
   */
      void
  script_prof_save(
***************
*** 1805,1816 ****
                fprintf(fd, "Cannot open file!\n");
            else
            {
!               for (i = 0; i < si->sn_prl_ga.ga_len; ++i)
                {
                    if (vim_fgets(IObuff, IOSIZE, sfd))
                        break;
!                   pp = &PRL_ITEM(si, i);
!                   if (pp->snp_count > 0)
                    {
                        fprintf(fd, "%5d ", pp->snp_count);
                        if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self))
--- 1805,1818 ----
                fprintf(fd, "Cannot open file!\n");
            else
            {
!               /* Keep going till the end of file, so that trailing
!                * continuation lines are listed. */
!               for (i = 0; ; ++i)
                {
                    if (vim_fgets(IObuff, IOSIZE, sfd))
                        break;
!                   if (i < si->sn_prl_ga.ga_len
!                                    && (pp = &PRL_ITEM(si, i))->snp_count > 0)
                    {
                        fprintf(fd, "%5d ", pp->snp_count);
                        if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self))
***************
*** 4234,4260 ****
      save_sourcing_lnum = sourcing_lnum;
      sourcing_lnum = 0;
  
- #ifdef FEAT_MBYTE
-     cookie.conv.vc_type = CONV_NONE;          /* no conversion */
- 
-     /* Read the first line so we can check for a UTF-8 BOM. */
-     firstline = getsourceline(0, (void *)&cookie, 0);
-     if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
-                             && firstline[1] == 0xbb && firstline[2] == 0xbf)
-     {
-       /* Found BOM; setup conversion, skip over BOM and recode the line. */
-       convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
-       p = string_convert(&cookie.conv, firstline + 3, NULL);
-       if (p == NULL)
-           p = vim_strsave(firstline + 3);
-       if (p != NULL)
-       {
-           vim_free(firstline);
-           firstline = p;
-       }
-     }
- #endif
- 
  #ifdef STARTUPTIME
      if (time_fd != NULL)
        time_push(&tv_rel, &tv_start);
--- 4236,4241 ----
***************
*** 4347,4352 ****
--- 4328,4354 ----
  # endif
  #endif
  
+ #ifdef FEAT_MBYTE
+     cookie.conv.vc_type = CONV_NONE;          /* no conversion */
+ 
+     /* Read the first line so we can check for a UTF-8 BOM. */
+     firstline = getsourceline(0, (void *)&cookie, 0);
+     if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
+                             && firstline[1] == 0xbb && firstline[2] == 0xbf)
+     {
+       /* Found BOM; setup conversion, skip over BOM and recode the line. */
+       convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
+       p = string_convert(&cookie.conv, firstline + 3, NULL);
+       if (p == NULL)
+           p = vim_strsave(firstline + 3);
+       if (p != NULL)
+       {
+           vim_free(firstline);
+           firstline = p;
+       }
+     }
+ #endif
+ 
      /*
       * Call do_cmdline, which will call getsourceline() to get the lines.
       */
***************
*** 4829,4835 ****
      {
        /* Grow the array before starting the timer, so that the time spent
         * here isn't counted. */
!       (void)ga_grow(&si->sn_prl_ga, (int)(sourcing_lnum - 
si->sn_prl_ga.ga_len));
        si->sn_prl_idx = sourcing_lnum - 1;
        while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
                && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen)
--- 4831,4838 ----
      {
        /* Grow the array before starting the timer, so that the time spent
         * here isn't counted. */
!       (void)ga_grow(&si->sn_prl_ga,
!                                 (int)(sourcing_lnum - si->sn_prl_ga.ga_len));
        si->sn_prl_idx = sourcing_lnum - 1;
        while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
                && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen)
***************
*** 4864,4870 ****
  }
  
  /*
!  * Called when done with a function line.
   */
      void
  script_line_end(void)
--- 4867,4873 ----
  }
  
  /*
!  * Called when done with a script line.
   */
      void
  script_line_end(void)
*** ../vim-8.0.1206/src/version.c       2017-10-19 18:35:46.094557713 +0200
--- src/version.c       2017-10-19 21:03:28.038337685 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1207,
  /**/

-- 
Vim is like Emacs without all the typing.  (John "Johann" Spetz)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui