Re: Patch 9.0.1175

2023-01-11 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 11-Jan-2023 22:46, Bram Moolenaar wrote:
> > Patch 9.0.1175
> > Problem:The set_ref_in_item() function is too long.
> > Solution:   Use a separate function for more complicated types. (Yegappan
> >  Lakshmanan, closes #11802)
> > Files:  src/eval.c
> >
> >
> >
> After this patch msys64 (clang 15.0.5) gives this error message:
> 
> clang -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
> -pipe -Wall -O3 -fomit-frame-pointer -fpie -fPIE -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD eval.c -o gobjx86-64/eval.o
> eval.c:5773:42: error: no member named 'v_job' in 'union 
> typval_S::(unnamed at ./structs.h:1548:5)'
>      return set_ref_in_item_job(tv->vval.v_job, copyID,
>      ^
> eval.c:5777:46: error: no member named 'v_channel' in 'union 
> typval_S::(unnamed at ./structs.h:1548:5)'
>      return set_ref_in_item_channel(tv->vval.v_channel, copyID,
>      ^
> 2 errors generated.
> make: *** [Make_cyg_ming.mak:1206: gobjx86-64/eval.o] Error 1
> 
> 
> The attached patch tries to fix it.

I'll include it, thanks.

-- 
While it's true that many normal people whould prefer not to _date_ an
engineer, most normal people harbor an intense desire to _mate_ with them,
thus producing engineerlike children who will have high-paying jobs long
before losing their virginity.
(Scott Adams - The Dilbert principle)

 /// 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/2023091146.6ABEA1C07A0%40moolenaar.net.


Re: Patch 9.0.1175

2023-01-11 Fir de Conversatie John Marriott


On 11-Jan-2023 22:46, Bram Moolenaar wrote:

Patch 9.0.1175
Problem:The set_ref_in_item() function is too long.
Solution:   Use a separate function for more complicated types. (Yegappan
 Lakshmanan, closes #11802)
Files:  src/eval.c




After this patch msys64 (clang 15.0.5) gives this error message:

clang -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -Wall -O3 -fomit-frame-pointer -fpie -fPIE -DFEAT_GUI_MSWIN 
-DFEAT_CLIPBOARD eval.c -o gobjx86-64/eval.o
eval.c:5773:42: error: no member named 'v_job' in 'union 
typval_S::(unnamed at ./structs.h:1548:5)'

    return set_ref_in_item_job(tv->vval.v_job, copyID,
    ^
eval.c:5777:46: error: no member named 'v_channel' in 'union 
typval_S::(unnamed at ./structs.h:1548:5)'

    return set_ref_in_item_channel(tv->vval.v_channel, copyID,
    ^
2 errors generated.
make: *** [Make_cyg_ming.mak:1206: gobjx86-64/eval.o] Error 1


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/029b4220-a6b3-5dcf-aa38-fec5b8709308%40internode.on.net.
--- eval.c.orig 2023-01-12 05:46:53.096761500 +1100
+++ eval.c  2023-01-12 06:01:15.55792 +1100
@@ -5580,6 +5580,7 @@
 return abort;
 }
 
+#ifdef FEAT_JOB_CHANNEL
 /*
  * Mark the job "pt" with "copyID".
  * Also see set_ref_in_item().
@@ -5591,7 +5592,6 @@
 ht_stack_T **ht_stack,
 list_stack_T   **list_stack)
 {
-#ifdef FEAT_JOB_CHANNEL
 typval_Tdtv;
 
 if (job == NULL || job->jv_copyID == copyID)
@@ -5610,7 +5610,6 @@
dtv.vval.v_partial = job->jv_exit_cb.cb_partial;
set_ref_in_item(, copyID, ht_stack, list_stack);
 }
-#endif
 
 return FALSE;
 }
@@ -5626,7 +5625,6 @@
 ht_stack_T **ht_stack,
 list_stack_T   **list_stack)
 {
-#ifdef FEAT_JOB_CHANNEL
 typval_Tdtv;
 
 if (ch == NULL || ch->ch_copyID == copyID)
@@ -5665,10 +5663,10 @@
dtv.vval.v_partial = ch->ch_close_cb.cb_partial;
set_ref_in_item(, copyID, ht_stack, list_stack);
 }
-#endif
 
 return FALSE;
 }
+#endif
 
 /*
  * Mark the class "cl" with "copyID".
@@ -5770,12 +5768,20 @@
ht_stack, list_stack);
 
case VAR_JOB:
+#ifdef FEAT_JOB_CHANNEL
return set_ref_in_item_job(tv->vval.v_job, copyID,
 ht_stack, list_stack);
+#else
+   break;
+#endif
 
case VAR_CHANNEL:
+#ifdef FEAT_JOB_CHANNEL
return set_ref_in_item_channel(tv->vval.v_channel, copyID,
 ht_stack, list_stack);
+#else
+   break;
+#endif
 
case VAR_CLASS:
return set_ref_in_item_class(tv->vval.v_class, copyID,


Patch 9.0.1175

2023-01-11 Fir de Conversatie Bram Moolenaar


Patch 9.0.1175
Problem:The set_ref_in_item() function is too long.
Solution:   Use a separate function for more complicated types. (Yegappan
Lakshmanan, closes #11802)
Files:  src/eval.c


*** ../vim-9.0.1174/src/eval.c  2023-01-06 18:42:16.434674109 +
--- src/eval.c  2023-01-11 11:44:37.922251835 +
***
*** 5484,5489 
--- 5484,5738 
  }
  
  /*
+  * Mark the dict "dd" with "copyID".
+  * Also see set_ref_in_item().
+  */
+ static int
+ set_ref_in_item_dict(
+ dict_T*dd,
+ int   copyID,
+ ht_stack_T**ht_stack,
+ list_stack_T  **list_stack)
+ {
+ if (dd == NULL || dd->dv_copyID == copyID)
+   return FALSE;
+ 
+ // Didn't see this dict yet.
+ dd->dv_copyID = copyID;
+ if (ht_stack == NULL)
+   return set_ref_in_ht(>dv_hashtab, copyID, list_stack);
+ 
+ ht_stack_T *newitem = ALLOC_ONE(ht_stack_T);
+ if (newitem == NULL)
+   return TRUE;
+ 
+ newitem->ht = >dv_hashtab;
+ newitem->prev = *ht_stack;
+ *ht_stack = newitem;
+ 
+ return FALSE;
+ }
+ 
+ /*
+  * Mark the list "ll" with "copyID".
+  * Also see set_ref_in_item().
+  */
+ static int
+ set_ref_in_item_list(
+ list_T*ll,
+ int   copyID,
+ ht_stack_T**ht_stack,
+ list_stack_T  **list_stack)
+ {
+ if (ll == NULL || ll->lv_copyID == copyID)
+   return FALSE;
+ 
+ // Didn't see this list yet.
+ ll->lv_copyID = copyID;
+ if (list_stack == NULL)
+   return set_ref_in_list_items(ll, copyID, ht_stack);
+ 
+ list_stack_T *newitem = ALLOC_ONE(list_stack_T);
+ if (newitem == NULL)
+   return TRUE;
+ 
+ newitem->list = ll;
+ newitem->prev = *list_stack;
+ *list_stack = newitem;
+ 
+ return FALSE;
+ }
+ 
+ /*
+  * Mark the partial "pt" with "copyID".
+  * Also see set_ref_in_item().
+  */
+ static int
+ set_ref_in_item_partial(
+ partial_T *pt,
+ int   copyID,
+ ht_stack_T**ht_stack,
+ list_stack_T  **list_stack)
+ {
+ if (pt == NULL || pt->pt_copyID == copyID)
+   return FALSE;
+ 
+ // Didn't see this partial yet.
+ pt->pt_copyID = copyID;
+ 
+ int abort = set_ref_in_func(pt->pt_name, pt->pt_func, copyID);
+ 
+ if (pt->pt_dict != NULL)
+ {
+   typval_T dtv;
+ 
+   dtv.v_type = VAR_DICT;
+   dtv.vval.v_dict = pt->pt_dict;
+   set_ref_in_item(, copyID, ht_stack, list_stack);
+ }
+ 
+ for (int i = 0; i < pt->pt_argc; ++i)
+   abort = abort || set_ref_in_item(>pt_argv[i], copyID,
+   ht_stack, list_stack);
+ // pt_funcstack is handled in set_ref_in_funcstacks()
+ // pt_loopvars is handled in set_ref_in_loopvars()
+ 
+ return abort;
+ }
+ 
+ /*
+  * Mark the job "pt" with "copyID".
+  * Also see set_ref_in_item().
+  */
+ static int
+ set_ref_in_item_job(
+ job_T *job,
+ int   copyID,
+ ht_stack_T**ht_stack,
+ list_stack_T  **list_stack)
+ {
+ #ifdef FEAT_JOB_CHANNEL
+ typval_Tdtv;
+ 
+ if (job == NULL || job->jv_copyID == copyID)
+   return FALSE;
+ 
+ job->jv_copyID = copyID;
+ if (job->jv_channel != NULL)
+ {
+   dtv.v_type = VAR_CHANNEL;
+   dtv.vval.v_channel = job->jv_channel;
+   set_ref_in_item(, copyID, ht_stack, list_stack);
+ }
+ if (job->jv_exit_cb.cb_partial != NULL)
+ {
+   dtv.v_type = VAR_PARTIAL;
+   dtv.vval.v_partial = job->jv_exit_cb.cb_partial;
+   set_ref_in_item(, copyID, ht_stack, list_stack);
+ }
+ #endif
+ 
+ return FALSE;
+ }
+ 
+ /*
+  * Mark the channel "ch" with "copyID".
+  * Also see set_ref_in_item().
+  */
+ static int
+ set_ref_in_item_channel(
+ channel_T *ch,
+ int   copyID,
+ ht_stack_T**ht_stack,
+ list_stack_T  **list_stack)
+ {
+ #ifdef FEAT_JOB_CHANNEL
+ typval_Tdtv;
+ 
+ if (ch == NULL || ch->ch_copyID == copyID)
+   return FALSE;
+ 
+ ch->ch_copyID = copyID;
+ for (ch_part_T part = PART_SOCK; part < PART_COUNT; ++part)
+ {
+   for (jsonq_T *jq = ch->ch_part[part].ch_json_head.jq_next;
+   jq != NULL; jq = jq->jq_next)
+   set_ref_in_item(jq->jq_value, copyID, ht_stack, list_stack);
+   for (cbq_T *cq = ch->ch_part[part].ch_cb_head.cq_next; cq != NULL;
+   cq = cq->cq_next)
+   if (cq->cq_callback.cb_partial != NULL)
+   {
+   dtv.v_type = VAR_PARTIAL;
+   dtv.vval.v_partial = cq->cq_callback.cb_partial;
+   set_ref_in_item(, copyID, ht_stack, list_