Re: Patch 8.2.4482

2022-02-28 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 28-Feb-2022 08:03, Bram Moolenaar wrote:
> > Patch 8.2.4482
> > Problem:No fuzzy cmdline completion for user defined completion.
> > Solution:   Add fuzzy completion for user defined completion. (Yegappan
> >  Lakshmanan, closes #9858)
> > Files:  src/cmdexpand.c, src/testdir/test_cmdline.vim
> >
> >
> >
> After this patch, mingw64 (gcc 11.2.0) throws this warning:
> 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
> -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD cmdexpand.c -o 
> gobjnative/cmdexpand.o
> cmdexpand.c: In function 'ExpandFromContext':
> cmdexpand.c:3056:33: warning: 'score' may be used uninitialized in this 
> function [-Wmaybe-uninitialized]
>   3056 | fuzmatch->score = score;
>    | ^~~
> cmdexpand.c:3006:17: note: 'score' was declared here
>   3006 | int score;
>    | ^
> 
> 
> The attached patch tries to fix it.

I'll include it, thanks.

-- 
Statistics say that you can have a baby per month on average:
Just get nine women pregnant.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220228210437.8861B1C02B3%40moolenaar.net.


Re: Patch 8.2.4482

2022-02-28 Fir de Conversatie John Marriott


On 28-Feb-2022 08:03, Bram Moolenaar wrote:

Patch 8.2.4482
Problem:No fuzzy cmdline completion for user defined completion.
Solution:   Add fuzzy completion for user defined completion. (Yegappan
 Lakshmanan, closes #9858)
Files:  src/cmdexpand.c, src/testdir/test_cmdline.vim




After this patch, mingw64 (gcc 11.2.0) throws this warning:

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD cmdexpand.c -o 
gobjnative/cmdexpand.o

cmdexpand.c: In function 'ExpandFromContext':
cmdexpand.c:3056:33: warning: 'score' may be used uninitialized in this 
function [-Wmaybe-uninitialized]

 3056 | fuzmatch->score = score;
  | ^~~
cmdexpand.c:3006:17: note: 'score' was declared here
 3006 | int score;
  | ^


The attached patch tries to fix it.
Cheers
John

--
--
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/3d9eba67-11c9-2f42-abb5-45cb756b7e4a%40internode.on.net.
--- cmdexpand.c.orig2022-03-01 05:56:52.611353000 +1100
+++ cmdexpand.c 2022-03-01 06:17:08.904664100 +1100
@@ -3003,7 +3003,7 @@
 garray_T   ga;
 intfuzzy;
 intmatch;
-intscore;
+intscore = 0;
 
 fuzzy = cmdline_fuzzy_complete(pat);
 *matches = NULL;


Patch 8.2.4482

2022-02-27 Fir de Conversatie Bram Moolenaar


Patch 8.2.4482
Problem:No fuzzy cmdline completion for user defined completion.
Solution:   Add fuzzy completion for user defined completion. (Yegappan
Lakshmanan, closes #9858)
Files:  src/cmdexpand.c, src/testdir/test_cmdline.vim


*** ../vim-8.2.4481/src/cmdexpand.c 2022-02-27 14:28:13.183994838 +
--- src/cmdexpand.c 2022-02-27 20:16:41.714037903 +
***
*** 16,30 
  static intcmd_showtail;   // Only show path tail in lists ?
  
  static void   set_expand_context(expand_T *xp);
! static int  ExpandGeneric(expand_T *xp, regmatch_T *regmatch,
  char_u ***matches, int *numMatches,
! char_u *((*func)(expand_T *, int)), int escaped,
! char_u *fuzzystr);
  static intExpandFromContext(expand_T *xp, char_u *, char_u ***, int *, 
int);
  static intexpand_showtail(expand_T *xp);
  static intexpand_shellcmd(char_u *filepat, char_u ***matches, int 
*numMatches, int flagsarg);
  #if defined(FEAT_EVAL)
! static intExpandUserDefined(expand_T *xp, regmatch_T *regmatch, char_u 
***matches, int *numMatches);
  static intExpandUserList(expand_T *xp, char_u ***matches, int 
*numMatches);
  #endif
  
--- 16,29 
  static intcmd_showtail;   // Only show path tail in lists ?
  
  static void   set_expand_context(expand_T *xp);
! static int  ExpandGeneric(char_u *pat, expand_T *xp, regmatch_T *regmatch,
  char_u ***matches, int *numMatches,
! char_u *((*func)(expand_T *, int)), int escaped);
  static intExpandFromContext(expand_T *xp, char_u *, char_u ***, int *, 
int);
  static intexpand_showtail(expand_T *xp);
  static intexpand_shellcmd(char_u *filepat, char_u ***matches, int 
*numMatches, int flagsarg);
  #if defined(FEAT_EVAL)
! static intExpandUserDefined(char_u *pat, expand_T *xp, regmatch_T 
*regmatch, char_u ***matches, int *numMatches);
  static intExpandUserList(expand_T *xp, char_u ***matches, int 
*numMatches);
  #endif
  
***
*** 62,74 
&& xp->xp_context != EXPAND_SHELLCMD
&& xp->xp_context != EXPAND_TAGS
&& xp->xp_context != EXPAND_TAGS_LISTFILES
-   && xp->xp_context != EXPAND_USER_DEFINED
&& xp->xp_context != EXPAND_USER_LIST);
  }
  
  /*
   * Returns TRUE if fuzzy completion for cmdline completion is enabled and
!  * 'fuzzystr' is not empty.
   */
  int
  cmdline_fuzzy_complete(char_u *fuzzystr)
--- 61,73 
&& xp->xp_context != EXPAND_SHELLCMD
&& xp->xp_context != EXPAND_TAGS
&& xp->xp_context != EXPAND_TAGS_LISTFILES
&& xp->xp_context != EXPAND_USER_LIST);
  }
  
  /*
   * Returns TRUE if fuzzy completion for cmdline completion is enabled and
!  * 'fuzzystr' is not empty.  If search pattern is empty, then don't use fuzzy
!  * matching.
   */
  int
  cmdline_fuzzy_complete(char_u *fuzzystr)
***
*** 2444,2459 
  {
if (xp->xp_context == tab[i].context)
{
-   // Use fuzzy matching if 'wildoptions' has 'fuzzy'.
-   // If no search pattern is supplied, then don't use fuzzy
-   // matching and return all the found items.
-   int fuzzy = cmdline_fuzzy_complete(pat);
- 
if (tab[i].ic)
rmp->rm_ic = TRUE;
!   ret = ExpandGeneric(xp, rmp, matches, numMatches,
!   tab[i].func, tab[i].escaped,
!   fuzzy ? pat : NULL);
break;
}
  }
--- 2443,2452 
  {
if (xp->xp_context == tab[i].context)
{
if (tab[i].ic)
rmp->rm_ic = TRUE;
!   ret = ExpandGeneric(pat, xp, rmp, matches, numMatches,
!   tab[i].func, tab[i].escaped);
break;
}
  }
***
*** 2604,2610 
ret = ExpandMappings(pat, , numMatches, matches);
  # if defined(FEAT_EVAL)
  else if (xp->xp_context == EXPAND_USER_DEFINED)
!   ret = ExpandUserDefined(xp, , matches, numMatches);
  # endif
  else
ret = ExpandOther(pat, xp, , matches, numMatches);
--- 2597,2603 
ret = ExpandMappings(pat, , numMatches, matches);
  # if defined(FEAT_EVAL)
  else if (xp->xp_context == EXPAND_USER_DEFINED)
!   ret = ExpandUserDefined(pat, xp, , matches, numMatches);
  # endif
  else
ret = ExpandOther(pat, xp, , matches, numMatches);
***
*** 2630,2643 
   */
  static int
  ExpandGeneric(
  expand_T  *xp,
  regmatch_T*regmatch,
  char_u***matches,
  int   *numMatches,
  char_u*((*func)(expand_T *, int)),