Mercurial > vim
comparison src/channel.c @ 8540:fec8655cf1bf v7.4.1560
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 14 23:22:59 2016 +0100
patch 7.4.1560
Problem: Dict options with a dash are more difficult to use.
Solution: Use an underscore, so that dict.err_io can be used.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 14 Mar 2016 23:30:05 +0100 |
parents | c337c813c64d |
children | 556817999955 |
comparison
equal
deleted
inserted
replaced
8539:5212782d6378 | 8540:fec8655cf1bf |
---|---|
3146 if (!(supported & JO_MODE)) | 3146 if (!(supported & JO_MODE)) |
3147 break; | 3147 break; |
3148 if (handle_mode(item, opt, &opt->jo_mode, JO_MODE) == FAIL) | 3148 if (handle_mode(item, opt, &opt->jo_mode, JO_MODE) == FAIL) |
3149 return FAIL; | 3149 return FAIL; |
3150 } | 3150 } |
3151 else if (STRCMP(hi->hi_key, "in-mode") == 0) | 3151 else if (STRCMP(hi->hi_key, "in_mode") == 0) |
3152 { | 3152 { |
3153 if (!(supported & JO_IN_MODE)) | 3153 if (!(supported & JO_IN_MODE)) |
3154 break; | 3154 break; |
3155 if (handle_mode(item, opt, &opt->jo_in_mode, JO_IN_MODE) | 3155 if (handle_mode(item, opt, &opt->jo_in_mode, JO_IN_MODE) |
3156 == FAIL) | 3156 == FAIL) |
3157 return FAIL; | 3157 return FAIL; |
3158 } | 3158 } |
3159 else if (STRCMP(hi->hi_key, "out-mode") == 0) | 3159 else if (STRCMP(hi->hi_key, "out_mode") == 0) |
3160 { | 3160 { |
3161 if (!(supported & JO_OUT_MODE)) | 3161 if (!(supported & JO_OUT_MODE)) |
3162 break; | 3162 break; |
3163 if (handle_mode(item, opt, &opt->jo_out_mode, JO_OUT_MODE) | 3163 if (handle_mode(item, opt, &opt->jo_out_mode, JO_OUT_MODE) |
3164 == FAIL) | 3164 == FAIL) |
3165 return FAIL; | 3165 return FAIL; |
3166 } | 3166 } |
3167 else if (STRCMP(hi->hi_key, "err-mode") == 0) | 3167 else if (STRCMP(hi->hi_key, "err_mode") == 0) |
3168 { | 3168 { |
3169 if (!(supported & JO_ERR_MODE)) | 3169 if (!(supported & JO_ERR_MODE)) |
3170 break; | 3170 break; |
3171 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) | 3171 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) |
3172 == FAIL) | 3172 == FAIL) |
3173 return FAIL; | 3173 return FAIL; |
3174 } | 3174 } |
3175 else if (STRCMP(hi->hi_key, "in-io") == 0 | 3175 else if (STRCMP(hi->hi_key, "in_io") == 0 |
3176 || STRCMP(hi->hi_key, "out-io") == 0 | 3176 || STRCMP(hi->hi_key, "out_io") == 0 |
3177 || STRCMP(hi->hi_key, "err-io") == 0) | 3177 || STRCMP(hi->hi_key, "err_io") == 0) |
3178 { | 3178 { |
3179 if (!(supported & JO_OUT_IO)) | 3179 if (!(supported & JO_OUT_IO)) |
3180 break; | 3180 break; |
3181 if (handle_io(item, part_from_char(*hi->hi_key), opt) == FAIL) | 3181 if (handle_io(item, part_from_char(*hi->hi_key), opt) == FAIL) |
3182 return FAIL; | 3182 return FAIL; |
3183 } | 3183 } |
3184 else if (STRCMP(hi->hi_key, "in-name") == 0 | 3184 else if (STRCMP(hi->hi_key, "in_name") == 0 |
3185 || STRCMP(hi->hi_key, "out-name") == 0 | 3185 || STRCMP(hi->hi_key, "out_name") == 0 |
3186 || STRCMP(hi->hi_key, "err-name") == 0) | 3186 || STRCMP(hi->hi_key, "err_name") == 0) |
3187 { | 3187 { |
3188 part = part_from_char(*hi->hi_key); | 3188 part = part_from_char(*hi->hi_key); |
3189 | 3189 |
3190 if (!(supported & JO_OUT_IO)) | 3190 if (!(supported & JO_OUT_IO)) |
3191 break; | 3191 break; |
3192 opt->jo_set |= JO_OUT_NAME << (part - PART_OUT); | 3192 opt->jo_set |= JO_OUT_NAME << (part - PART_OUT); |
3193 opt->jo_io_name[part] = | 3193 opt->jo_io_name[part] = |
3194 get_tv_string_buf_chk(item, opt->jo_io_name_buf[part]); | 3194 get_tv_string_buf_chk(item, opt->jo_io_name_buf[part]); |
3195 } | 3195 } |
3196 else if (STRCMP(hi->hi_key, "in-buf") == 0 | 3196 else if (STRCMP(hi->hi_key, "in_buf") == 0 |
3197 || STRCMP(hi->hi_key, "out-buf") == 0 | 3197 || STRCMP(hi->hi_key, "out_buf") == 0 |
3198 || STRCMP(hi->hi_key, "err-buf") == 0) | 3198 || STRCMP(hi->hi_key, "err_buf") == 0) |
3199 { | 3199 { |
3200 part = part_from_char(*hi->hi_key); | 3200 part = part_from_char(*hi->hi_key); |
3201 | 3201 |
3202 if (!(supported & JO_OUT_IO)) | 3202 if (!(supported & JO_OUT_IO)) |
3203 break; | 3203 break; |
3212 { | 3212 { |
3213 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[part]); | 3213 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[part]); |
3214 return FAIL; | 3214 return FAIL; |
3215 } | 3215 } |
3216 } | 3216 } |
3217 else if (STRCMP(hi->hi_key, "in-top") == 0 | 3217 else if (STRCMP(hi->hi_key, "in_top") == 0 |
3218 || STRCMP(hi->hi_key, "in-bot") == 0) | 3218 || STRCMP(hi->hi_key, "in_bot") == 0) |
3219 { | 3219 { |
3220 linenr_T *lp; | 3220 linenr_T *lp; |
3221 | 3221 |
3222 if (!(supported & JO_OUT_IO)) | 3222 if (!(supported & JO_OUT_IO)) |
3223 break; | 3223 break; |
3260 { | 3260 { |
3261 EMSG2(_(e_invarg2), "callback"); | 3261 EMSG2(_(e_invarg2), "callback"); |
3262 return FAIL; | 3262 return FAIL; |
3263 } | 3263 } |
3264 } | 3264 } |
3265 else if (STRCMP(hi->hi_key, "out-cb") == 0) | 3265 else if (STRCMP(hi->hi_key, "out_cb") == 0) |
3266 { | 3266 { |
3267 if (!(supported & JO_OUT_CALLBACK)) | 3267 if (!(supported & JO_OUT_CALLBACK)) |
3268 break; | 3268 break; |
3269 opt->jo_set |= JO_OUT_CALLBACK; | 3269 opt->jo_set |= JO_OUT_CALLBACK; |
3270 opt->jo_out_cb = get_callback(item, &opt->jo_out_partial); | 3270 opt->jo_out_cb = get_callback(item, &opt->jo_out_partial); |
3271 if (opt->jo_out_cb == NULL) | 3271 if (opt->jo_out_cb == NULL) |
3272 { | 3272 { |
3273 EMSG2(_(e_invarg2), "out-cb"); | 3273 EMSG2(_(e_invarg2), "out_cb"); |
3274 return FAIL; | 3274 return FAIL; |
3275 } | 3275 } |
3276 } | 3276 } |
3277 else if (STRCMP(hi->hi_key, "err-cb") == 0) | 3277 else if (STRCMP(hi->hi_key, "err_cb") == 0) |
3278 { | 3278 { |
3279 if (!(supported & JO_ERR_CALLBACK)) | 3279 if (!(supported & JO_ERR_CALLBACK)) |
3280 break; | 3280 break; |
3281 opt->jo_set |= JO_ERR_CALLBACK; | 3281 opt->jo_set |= JO_ERR_CALLBACK; |
3282 opt->jo_err_cb = get_callback(item, &opt->jo_err_partial); | 3282 opt->jo_err_cb = get_callback(item, &opt->jo_err_partial); |
3283 if (opt->jo_err_cb == NULL) | 3283 if (opt->jo_err_cb == NULL) |
3284 { | 3284 { |
3285 EMSG2(_(e_invarg2), "err-cb"); | 3285 EMSG2(_(e_invarg2), "err_cb"); |
3286 return FAIL; | 3286 return FAIL; |
3287 } | 3287 } |
3288 } | 3288 } |
3289 else if (STRCMP(hi->hi_key, "close-cb") == 0) | 3289 else if (STRCMP(hi->hi_key, "close_cb") == 0) |
3290 { | 3290 { |
3291 if (!(supported & JO_CLOSE_CALLBACK)) | 3291 if (!(supported & JO_CLOSE_CALLBACK)) |
3292 break; | 3292 break; |
3293 opt->jo_set |= JO_CLOSE_CALLBACK; | 3293 opt->jo_set |= JO_CLOSE_CALLBACK; |
3294 opt->jo_close_cb = get_callback(item, &opt->jo_close_partial); | 3294 opt->jo_close_cb = get_callback(item, &opt->jo_close_partial); |
3295 if (opt->jo_close_cb == NULL) | 3295 if (opt->jo_close_cb == NULL) |
3296 { | 3296 { |
3297 EMSG2(_(e_invarg2), "close-cb"); | 3297 EMSG2(_(e_invarg2), "close_cb"); |
3298 return FAIL; | 3298 return FAIL; |
3299 } | 3299 } |
3300 } | 3300 } |
3301 else if (STRCMP(hi->hi_key, "waittime") == 0) | 3301 else if (STRCMP(hi->hi_key, "waittime") == 0) |
3302 { | 3302 { |
3310 if (!(supported & JO_TIMEOUT)) | 3310 if (!(supported & JO_TIMEOUT)) |
3311 break; | 3311 break; |
3312 opt->jo_set |= JO_TIMEOUT; | 3312 opt->jo_set |= JO_TIMEOUT; |
3313 opt->jo_timeout = get_tv_number(item); | 3313 opt->jo_timeout = get_tv_number(item); |
3314 } | 3314 } |
3315 else if (STRCMP(hi->hi_key, "out-timeout") == 0) | 3315 else if (STRCMP(hi->hi_key, "out_timeout") == 0) |
3316 { | 3316 { |
3317 if (!(supported & JO_OUT_TIMEOUT)) | 3317 if (!(supported & JO_OUT_TIMEOUT)) |
3318 break; | 3318 break; |
3319 opt->jo_set |= JO_OUT_TIMEOUT; | 3319 opt->jo_set |= JO_OUT_TIMEOUT; |
3320 opt->jo_out_timeout = get_tv_number(item); | 3320 opt->jo_out_timeout = get_tv_number(item); |
3321 } | 3321 } |
3322 else if (STRCMP(hi->hi_key, "err-timeout") == 0) | 3322 else if (STRCMP(hi->hi_key, "err_timeout") == 0) |
3323 { | 3323 { |
3324 if (!(supported & JO_ERR_TIMEOUT)) | 3324 if (!(supported & JO_ERR_TIMEOUT)) |
3325 break; | 3325 break; |
3326 opt->jo_set |= JO_ERR_TIMEOUT; | 3326 opt->jo_set |= JO_ERR_TIMEOUT; |
3327 opt->jo_err_timeout = get_tv_number(item); | 3327 opt->jo_err_timeout = get_tv_number(item); |
3358 { | 3358 { |
3359 EMSG2(_(e_invarg2), "stoponexit"); | 3359 EMSG2(_(e_invarg2), "stoponexit"); |
3360 return FAIL; | 3360 return FAIL; |
3361 } | 3361 } |
3362 } | 3362 } |
3363 else if (STRCMP(hi->hi_key, "exit-cb") == 0) | 3363 else if (STRCMP(hi->hi_key, "exit_cb") == 0) |
3364 { | 3364 { |
3365 if (!(supported & JO_EXIT_CB)) | 3365 if (!(supported & JO_EXIT_CB)) |
3366 break; | 3366 break; |
3367 opt->jo_set |= JO_EXIT_CB; | 3367 opt->jo_set |= JO_EXIT_CB; |
3368 if (item->v_type == VAR_PARTIAL && item->vval.v_partial != NULL) | 3368 if (item->v_type == VAR_PARTIAL && item->vval.v_partial != NULL) |
3373 else | 3373 else |
3374 opt->jo_exit_cb = get_tv_string_buf_chk( | 3374 opt->jo_exit_cb = get_tv_string_buf_chk( |
3375 item, opt->jo_ecb_buf); | 3375 item, opt->jo_ecb_buf); |
3376 if (opt->jo_exit_cb == NULL) | 3376 if (opt->jo_exit_cb == NULL) |
3377 { | 3377 { |
3378 EMSG2(_(e_invarg2), "exit-cb"); | 3378 EMSG2(_(e_invarg2), "exit_cb"); |
3379 return FAIL; | 3379 return FAIL; |
3380 } | 3380 } |
3381 } | 3381 } |
3382 else | 3382 else |
3383 break; | 3383 break; |
3544 if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) | 3544 if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) |
3545 mch_stop_job(job, job->jv_stoponexit); | 3545 mch_stop_job(job, job->jv_stoponexit); |
3546 } | 3546 } |
3547 | 3547 |
3548 /* | 3548 /* |
3549 * Called once in a while: check if any jobs with an "exit-cb" have ended. | 3549 * Called once in a while: check if any jobs with an "exit_cb" have ended. |
3550 */ | 3550 */ |
3551 void | 3551 void |
3552 job_check_ended(void) | 3552 job_check_ended(void) |
3553 { | 3553 { |
3554 static time_t last_check = 0; | 3554 static time_t last_check = 0; |
3607 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) | 3607 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) |
3608 && opt.jo_io[part] == JIO_FILE | 3608 && opt.jo_io[part] == JIO_FILE |
3609 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) | 3609 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) |
3610 || *opt.jo_io_name[part] == NUL)) | 3610 || *opt.jo_io_name[part] == NUL)) |
3611 { | 3611 { |
3612 EMSG(_("E920: -io file requires -name to be set")); | 3612 EMSG(_("E920: _io file requires _name to be set")); |
3613 return job; | 3613 return job; |
3614 } | 3614 } |
3615 | 3615 |
3616 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) | 3616 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) |
3617 { | 3617 { |
3624 if (buf == NULL) | 3624 if (buf == NULL) |
3625 EMSGN(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); | 3625 EMSGN(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); |
3626 } | 3626 } |
3627 else if (!(opt.jo_set & JO_IN_NAME)) | 3627 else if (!(opt.jo_set & JO_IN_NAME)) |
3628 { | 3628 { |
3629 EMSG(_("E915: in-io buffer requires in-buf or in-name to be set")); | 3629 EMSG(_("E915: in_io buffer requires in_buf or in_name to be set")); |
3630 } | 3630 } |
3631 else | 3631 else |
3632 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); | 3632 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); |
3633 if (buf == NULL) | 3633 if (buf == NULL) |
3634 return job; | 3634 return job; |
3835 nr = job->jv_proc_info.dwProcessId; | 3835 nr = job->jv_proc_info.dwProcessId; |
3836 #endif | 3836 #endif |
3837 dict_add_nr_str(dict, "process", nr, NULL); | 3837 dict_add_nr_str(dict, "process", nr, NULL); |
3838 | 3838 |
3839 dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL); | 3839 dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL); |
3840 dict_add_nr_str(dict, "exit-cb", 0L, job->jv_exit_cb); | 3840 dict_add_nr_str(dict, "exit_cb", 0L, job->jv_exit_cb); |
3841 dict_add_nr_str(dict, "stoponexit", 0L, job->jv_stoponexit); | 3841 dict_add_nr_str(dict, "stoponexit", 0L, job->jv_stoponexit); |
3842 } | 3842 } |
3843 | 3843 |
3844 int | 3844 int |
3845 job_stop(job_T *job, typval_T *argvars) | 3845 job_stop(job_T *job, typval_T *argvars) |