@@ -9850,6 +9850,68 @@ f_ceil(typval_T *argvars, typval_T *rettv)
9850
9850
}
9851
9851
#endif
9852
9852
9853
+ #if defined(FEAT_CHANNEL) || defined(FEAT_JOB)
9854
+ /*
9855
+ * Get a callback from "arg". It can be a Funcref or a function name.
9856
+ * When "arg" is zero return an empty string.
9857
+ * Return NULL for an invalid argument.
9858
+ */
9859
+ static char_u *
9860
+ get_callback(typval_T *arg)
9861
+ {
9862
+ if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING)
9863
+ return arg->vval.v_string;
9864
+ if (arg->v_type == VAR_NUMBER && arg->vval.v_number == 0)
9865
+ return (char_u *)"";
9866
+ EMSG(_("E999: Invalid callback argument"));
9867
+ return NULL;
9868
+ }
9869
+
9870
+ /*
9871
+ * Get the option entries from "dict", and parse them.
9872
+ * If an option value is invalid return FAIL.
9873
+ */
9874
+ static int
9875
+ get_job_options(dict_T *dict, jobopt_T *opt)
9876
+ {
9877
+ dictitem_T *item;
9878
+ char_u *mode;
9879
+
9880
+ if (dict == NULL)
9881
+ return OK;
9882
+
9883
+ if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL)
9884
+ {
9885
+ mode = get_tv_string(&item->di_tv);
9886
+ if (STRCMP(mode, "nl") == 0)
9887
+ opt->jo_mode = MODE_NL;
9888
+ else if (STRCMP(mode, "raw") == 0)
9889
+ opt->jo_mode = MODE_RAW;
9890
+ else if (STRCMP(mode, "js") == 0)
9891
+ opt->jo_mode = MODE_JS;
9892
+ else if (STRCMP(mode, "json") == 0)
9893
+ opt->jo_mode = MODE_JSON;
9894
+ else
9895
+ {
9896
+ EMSG2(_(e_invarg2), mode);
9897
+ return FAIL;
9898
+ }
9899
+ }
9900
+
9901
+ if ((item = dict_find(dict, (char_u *)"callback", -1)) != NULL)
9902
+ {
9903
+ opt->jo_callback = get_callback(&item->di_tv);
9904
+ if (opt->jo_callback == NULL)
9905
+ {
9906
+ EMSG2(_(e_invarg2), "callback");
9907
+ return FAIL;
9908
+ }
9909
+ }
9910
+
9911
+ return OK;
9912
+ }
9913
+ #endif
9914
+
9853
9915
#ifdef FEAT_CHANNEL
9854
9916
/*
9855
9917
* Get the channel from the argument.
@@ -9887,22 +9949,6 @@ f_ch_close(typval_T *argvars, typval_T *rettv UNUSED)
9887
9949
channel_close(channel);
9888
9950
}
9889
9951
9890
- /*
9891
- * Get a callback from "arg". It can be a Funcref or a function name.
9892
- * When "arg" is zero return an empty string.
9893
- * Return NULL for an invalid argument.
9894
- */
9895
- static char_u *
9896
- get_callback(typval_T *arg)
9897
- {
9898
- if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING)
9899
- return arg->vval.v_string;
9900
- if (arg->v_type == VAR_NUMBER && arg->vval.v_number == 0)
9901
- return (char_u *)"";
9902
- EMSG(_("E999: Invalid callback argument"));
9903
- return NULL;
9904
- }
9905
-
9906
9952
/*
9907
9953
* "ch_logfile()" function
9908
9954
*/
@@ -9929,50 +9975,6 @@ f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED)
9929
9975
ch_logfile(file);
9930
9976
}
9931
9977
9932
- /*
9933
- * Get the option entries from "dict", and parse them.
9934
- * If an option value is invalid return FAIL.
9935
- */
9936
- static int
9937
- get_job_options(dict_T *dict, jobopt_T *opt)
9938
- {
9939
- dictitem_T *item;
9940
- char_u *mode;
9941
-
9942
- if (dict == NULL)
9943
- return OK;
9944
-
9945
- if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL)
9946
- {
9947
- mode = get_tv_string(&item->di_tv);
9948
- if (STRCMP(mode, "nl") == 0)
9949
- opt->jo_mode = MODE_NL;
9950
- else if (STRCMP(mode, "raw") == 0)
9951
- opt->jo_mode = MODE_RAW;
9952
- else if (STRCMP(mode, "js") == 0)
9953
- opt->jo_mode = MODE_JS;
9954
- else if (STRCMP(mode, "json") == 0)
9955
- opt->jo_mode = MODE_JSON;
9956
- else
9957
- {
9958
- EMSG2(_(e_invarg2), mode);
9959
- return FAIL;
9960
- }
9961
- }
9962
-
9963
- if ((item = dict_find(dict, (char_u *)"callback", -1)) != NULL)
9964
- {
9965
- opt->jo_callback = get_callback(&item->di_tv);
9966
- if (opt->jo_callback == NULL)
9967
- {
9968
- EMSG2(_(e_invarg2), "callback");
9969
- return FAIL;
9970
- }
9971
- }
9972
-
9973
- return OK;
9974
- }
9975
-
9976
9978
/*
9977
9979
* "ch_open()" function
9978
9980
*/
0 commit comments