Re: Patch 8.2.3536

2021-10-19 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 19-Oct-2021 08:14, Bram Moolenaar wrote:
> > Patch 8.2.3536
> > Problem:The do_highlight() function is way too long.
> > Solution:   Split it into several functions. (Yegappan Lakshmanan,
> >  closes #9011)
> > Files:  src/highlight.c
> >
> >
> >
> After this patch mingw64 (gcc 11.2) throws these warnings when *not* 
> compiled as a GUI:
> 
> 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  highlight.c -o objnative/highlight.o
> highlight.c: In function 'highlight_set_guifg':
> highlight.c::17: warning: unused variable 'i' [-Wunused-variable]
>    | long    i;
>    | ^
> highlight.c: In function 'highlight_set_guibg':
> highlight.c:1178:17: warning: unused variable 'i' [-Wunused-variable]
>   1178 | int i;
>    | ^
> 
> 
> Attached is a patch that tries to fix it, but I'm not sure that it's 
> correct.

A slightly different #ifdef is needed, like where "i" is used.
Thanks for pointing out the location.

-- 
hundred-and-one symptoms of being an internet addict:
201. When somebody asks you where you are, you tell them in which chat room.

 /// 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/20211019192459.A5BD3C80053%40moolenaar.net.


Re: Patch 8.2.3536

2021-10-19 Fir de Conversatie John Marriott


On 19-Oct-2021 08:14, Bram Moolenaar wrote:

Patch 8.2.3536
Problem:The do_highlight() function is way too long.
Solution:   Split it into several functions. (Yegappan Lakshmanan,
 closes #9011)
Files:  src/highlight.c



After this patch mingw64 (gcc 11.2) throws these warnings when *not* 
compiled as a GUI:


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  highlight.c -o objnative/highlight.o

highlight.c: In function 'highlight_set_guifg':
highlight.c::17: warning: unused variable 'i' [-Wunused-variable]
  | long    i;
  | ^
highlight.c: In function 'highlight_set_guibg':
highlight.c:1178:17: warning: unused variable 'i' [-Wunused-variable]
 1178 | int i;
  | ^


Attached is a patch that tries to fix it, but I'm not sure that it's 
correct.

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/6acebb2e-0d71-f006-ef80-ba00c4ead520%40internode.on.net.
1110a
> # if defined(FEAT_GUI)
a1113
> #endif
1177a1180
> # if defined(FEAT_GUI)
1178a1182
> #endif


Patch 8.2.3536

2021-10-18 Fir de Conversatie Bram Moolenaar


Patch 8.2.3536
Problem:The do_highlight() function is way too long.
Solution:   Split it into several functions. (Yegappan Lakshmanan,
closes #9011)
Files:  src/highlight.c


*** ../vim-8.2.3535/src/highlight.c 2021-10-15 22:25:37.785385044 +0100
--- src/highlight.c 2021-10-18 22:12:59.041516541 +0100
***
*** 377,386 
  #ifdef FEAT_EVAL
  char_u*p;
  
! /*
!  * Try finding the color scheme file.  Used when a color file was loaded
!  * and 'background' or 't_Co' is changed.
!  */
  p = get_var_value((char_u *)"g:colors_name");
  if (p != NULL)
  {
--- 377,384 
  #ifdef FEAT_EVAL
  char_u*p;
  
! // Try finding the color scheme file.  Used when a color file was loaded
! // and 'background' or 't_Co' is changed.
  p = get_var_value((char_u *)"g:colors_name");
  if (p != NULL)
  {
***
*** 400,408 
  
  #endif
  
! /*
!  * Didn't use a color file, use the compiled-in colors.
!  */
  if (both)
  {
had_both = TRUE;
--- 398,404 
  
  #endif
  
! // Didn't use a color file, use the compiled-in colors.
  if (both)
  {
had_both = TRUE;
***
*** 441,449 
  }
  
  #ifdef FEAT_SYN_HL
! /*
!  * If syntax highlighting is enabled load the highlighting for it.
!  */
  if (get_var_value((char_u *)"g:syntax_on") != NULL)
  {
static int  recursive = 0;
--- 437,443 
  }
  
  #ifdef FEAT_SYN_HL
! // If syntax highlighting is enabled load the highlighting for it.
  if (get_var_value((char_u *)"g:syntax_on") != NULL)
  {
static int  recursive = 0;
***
*** 581,591 
  else if (t_colors == 16 || t_colors == 88
   || t_colors >= 256)
  {
!   /*
!* Guess: if the termcap entry ends in 'm', it is
!* probably an xterm-like terminal.  Use the changed
!* order for colors.
!*/
if (*T_CAF != NUL)
p = T_CAF;
else
--- 575,583 
  else if (t_colors == 16 || t_colors == 88
   || t_colors >= 256)
  {
!   // Guess: if the termcap entry ends in 'm', it is
!   // probably an xterm-like terminal.  Use the changed
!   // order for colors.
if (*T_CAF != NUL)
p = T_CAF;
else
***
*** 611,616 
--- 603,1360 
  }
  
  /*
+  * Link highlight group 'from_hg' to 'to_hg'.
+  * 'dodefault' is set to TRUE for ":highlight default link".
+  * 'forceit' is set to TRUE for ":higlight! link"
+  * 'init' is set to TRUE when initializing all the highlight groups.
+  */
+ static void
+ highlight_group_link(
+   char_u  *from_hg,
+   int from_len,
+   char_u  *to_hg,
+   int to_len,
+   int dodefault,
+   int forceit,
+   int init)
+ {
+ int   from_id;
+ int   to_id;
+ hl_group_T*hlgroup = NULL;
+ 
+ from_id = syn_check_group(from_hg, from_len);
+ if (STRNCMP(to_hg, "NONE", 4) == 0)
+   to_id = 0;
+ else
+   to_id = syn_check_group(to_hg, to_len);
+ 
+ if (from_id > 0)
+ {
+   hlgroup = &HL_TABLE()[from_id - 1];
+   if (dodefault && (forceit || hlgroup->sg_deflink == 0))
+   {
+   hlgroup->sg_deflink = to_id;
+ #ifdef FEAT_EVAL
+   hlgroup->sg_deflink_sctx = current_sctx;
+   hlgroup->sg_deflink_sctx.sc_lnum += SOURCING_LNUM;
+ #endif
+   }
+ }
+ 
+ if (from_id > 0 && (!init || hlgroup->sg_set == 0))
+ {
+   // Don't allow a link when there already is some highlighting
+   // for the group, unless '!' is used
+   if (to_id > 0 && !forceit && !init
+   && hl_has_settings(from_id - 1, dodefault))
+   {
+   if (SOURCING_NAME == NULL && !dodefault)
+   emsg(_("E414: group has settings, highlight link ignored"));
+   }
+   else if (hlgroup->sg_link != to_id
+ #ifdef FEAT_EVAL
+   || hlgroup->sg_script_ctx.sc_sid != current_sctx.sc_sid
+ #endif
+   || hlgroup->sg_cleared)
+   {
+   if (!init)
+   hlgroup->sg_set |= SG_LINK;
+   hlgroup->sg_link = to_id;
+ #ifdef FEAT_EVAL
+   hlgroup->sg_script_ctx = current_sctx;
+   hlgroup->sg_script_ctx.sc_lnum += SOURCING_LNUM;
+ #endif
+   hlgroup->sg_cleared = FALSE;
+   redraw_all_later(SOME_VALID);
+ 
+   // Only call highlight_changed() once after multiple changes.
+   need_highlight_changed =