Mercurial > vim
comparison src/channel.c @ 15470:55ccc2d353bd v8.1.0743
patch 8.1.0743: giving error messages is not flexible
commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 13 23:38:42 2019 +0100
patch 8.1.0743: giving error messages is not flexible
Problem: Giving error messages is not flexible.
Solution: Add semsg(). Change argument from "char_u *" to "char *", also
for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes
#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Jan 2019 23:45:08 +0100 |
parents | 1d2b5c016f17 |
children | 69207f77754a |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
114 if (*fname != NUL) | 114 if (*fname != NUL) |
115 { | 115 { |
116 file = fopen((char *)fname, *opt == 'w' ? "w" : "a"); | 116 file = fopen((char *)fname, *opt == 'w' ? "w" : "a"); |
117 if (file == NULL) | 117 if (file == NULL) |
118 { | 118 { |
119 EMSG2(_(e_notopen), fname); | 119 semsg(_(e_notopen), fname); |
120 return; | 120 return; |
121 } | 121 } |
122 } | 122 } |
123 log_fd = file; | 123 log_fd = file; |
124 | 124 |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 #ifdef _WIN32 | 210 #ifdef _WIN32 |
211 # undef PERROR | 211 # undef PERROR |
212 # define PERROR(msg) (void)emsg3((char_u *)"%s: %s", \ | 212 # define PERROR(msg) (void)semsg("%s: %s", msg, strerror_win32(errno)) |
213 (char_u *)msg, (char_u *)strerror_win32(errno)) | |
214 | 213 |
215 static char * | 214 static char * |
216 strerror_win32(int eno) | 215 strerror_win32(int eno) |
217 { | 216 { |
218 static LPVOID msgbuf = NULL; | 217 static LPVOID msgbuf = NULL; |
940 | 939 |
941 address = tv_get_string(&argvars[0]); | 940 address = tv_get_string(&argvars[0]); |
942 if (argvars[1].v_type != VAR_UNKNOWN | 941 if (argvars[1].v_type != VAR_UNKNOWN |
943 && (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)) | 942 && (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)) |
944 { | 943 { |
945 EMSG(_(e_invarg)); | 944 emsg(_(e_invarg)); |
946 return NULL; | 945 return NULL; |
947 } | 946 } |
948 | 947 |
949 /* parse address */ | 948 /* parse address */ |
950 p = vim_strchr(address, ':'); | 949 p = vim_strchr(address, ':'); |
951 if (p == NULL) | 950 if (p == NULL) |
952 { | 951 { |
953 EMSG2(_(e_invarg2), address); | 952 semsg(_(e_invarg2), address); |
954 return NULL; | 953 return NULL; |
955 } | 954 } |
956 *p++ = NUL; | 955 *p++ = NUL; |
957 port = strtol((char *)p, &rest, 10); | 956 port = strtol((char *)p, &rest, 10); |
958 if (*address == NUL || port <= 0 || *rest != NUL) | 957 if (*address == NUL || port <= 0 || *rest != NUL) |
959 { | 958 { |
960 p[-1] = ':'; | 959 p[-1] = ':'; |
961 EMSG2(_(e_invarg2), address); | 960 semsg(_(e_invarg2), address); |
962 return NULL; | 961 return NULL; |
963 } | 962 } |
964 | 963 |
965 /* parse options */ | 964 /* parse options */ |
966 clear_job_options(&opt); | 965 clear_job_options(&opt); |
969 if (get_job_options(&argvars[1], &opt, | 968 if (get_job_options(&argvars[1], &opt, |
970 JO_MODE_ALL + JO_CB_ALL + JO_WAITTIME + JO_TIMEOUT_ALL, 0) == FAIL) | 969 JO_MODE_ALL + JO_CB_ALL + JO_WAITTIME + JO_TIMEOUT_ALL, 0) == FAIL) |
971 goto theend; | 970 goto theend; |
972 if (opt.jo_timeout < 0) | 971 if (opt.jo_timeout < 0) |
973 { | 972 { |
974 EMSG(_(e_invarg)); | 973 emsg(_(e_invarg)); |
975 goto theend; | 974 goto theend; |
976 } | 975 } |
977 | 976 |
978 channel = channel_open((char *)address, port, opt.jo_waittime, NULL); | 977 channel = channel_open((char *)address, port, opt.jo_waittime, NULL); |
979 if (channel != NULL) | 978 if (channel != NULL) |
1231 channel->ch_part[PART_OUT].ch_mode = MODE_NL; | 1230 channel->ch_part[PART_OUT].ch_mode = MODE_NL; |
1232 if (opt->jo_set & JO_OUT_BUF) | 1231 if (opt->jo_set & JO_OUT_BUF) |
1233 { | 1232 { |
1234 buf = buflist_findnr(opt->jo_io_buf[PART_OUT]); | 1233 buf = buflist_findnr(opt->jo_io_buf[PART_OUT]); |
1235 if (buf == NULL) | 1234 if (buf == NULL) |
1236 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]); | 1235 semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]); |
1237 } | 1236 } |
1238 else | 1237 else |
1239 { | 1238 { |
1240 int msg = TRUE; | 1239 int msg = TRUE; |
1241 | 1240 |
1249 channel->ch_part[PART_OUT].ch_nomodifiable = | 1248 channel->ch_part[PART_OUT].ch_nomodifiable = |
1250 !opt->jo_modifiable[PART_OUT]; | 1249 !opt->jo_modifiable[PART_OUT]; |
1251 | 1250 |
1252 if (!buf->b_p_ma && !channel->ch_part[PART_OUT].ch_nomodifiable) | 1251 if (!buf->b_p_ma && !channel->ch_part[PART_OUT].ch_nomodifiable) |
1253 { | 1252 { |
1254 EMSG(_(e_modifiable)); | 1253 emsg(_(e_modifiable)); |
1255 } | 1254 } |
1256 else | 1255 else |
1257 { | 1256 { |
1258 ch_log(channel, "writing out to buffer '%s'", | 1257 ch_log(channel, "writing out to buffer '%s'", |
1259 (char *)buf->b_ffname); | 1258 (char *)buf->b_ffname); |
1278 buf = channel->ch_part[PART_OUT].ch_bufref.br_buf; | 1277 buf = channel->ch_part[PART_OUT].ch_bufref.br_buf; |
1279 else if (opt->jo_set & JO_ERR_BUF) | 1278 else if (opt->jo_set & JO_ERR_BUF) |
1280 { | 1279 { |
1281 buf = buflist_findnr(opt->jo_io_buf[PART_ERR]); | 1280 buf = buflist_findnr(opt->jo_io_buf[PART_ERR]); |
1282 if (buf == NULL) | 1281 if (buf == NULL) |
1283 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]); | 1282 semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]); |
1284 } | 1283 } |
1285 else | 1284 else |
1286 { | 1285 { |
1287 int msg = TRUE; | 1286 int msg = TRUE; |
1288 | 1287 |
1295 if (opt->jo_set & JO_ERR_MODIFIABLE) | 1294 if (opt->jo_set & JO_ERR_MODIFIABLE) |
1296 channel->ch_part[PART_ERR].ch_nomodifiable = | 1295 channel->ch_part[PART_ERR].ch_nomodifiable = |
1297 !opt->jo_modifiable[PART_ERR]; | 1296 !opt->jo_modifiable[PART_ERR]; |
1298 if (!buf->b_p_ma && !channel->ch_part[PART_ERR].ch_nomodifiable) | 1297 if (!buf->b_p_ma && !channel->ch_part[PART_ERR].ch_nomodifiable) |
1299 { | 1298 { |
1300 EMSG(_(e_modifiable)); | 1299 emsg(_(e_modifiable)); |
1301 } | 1300 } |
1302 else | 1301 else |
1303 { | 1302 { |
1304 ch_log(channel, "writing err to buffer '%s'", | 1303 ch_log(channel, "writing err to buffer '%s'", |
1305 (char *)buf->b_ffname); | 1304 (char *)buf->b_ffname); |
1617 { | 1616 { |
1618 typval_T rettv; | 1617 typval_T rettv; |
1619 int dummy; | 1618 int dummy; |
1620 | 1619 |
1621 if (safe_to_invoke_callback == 0) | 1620 if (safe_to_invoke_callback == 0) |
1622 IEMSG("INTERNAL: Invoking callback when it is not safe"); | 1621 iemsg("INTERNAL: Invoking callback when it is not safe"); |
1623 | 1622 |
1624 argv[0].v_type = VAR_CHANNEL; | 1623 argv[0].v_type = VAR_CHANNEL; |
1625 argv[0].vval.v_channel = channel; | 1624 argv[0].vval.v_channel = channel; |
1626 | 1625 |
1627 call_func(callback, (int)STRLEN(callback), &rettv, 2, argv, NULL, | 1626 call_func(callback, (int)STRLEN(callback), &rettv, 2, argv, NULL, |
2235 | 2234 |
2236 if (argv[1].v_type != VAR_STRING) | 2235 if (argv[1].v_type != VAR_STRING) |
2237 { | 2236 { |
2238 ch_error(channel, "received command with non-string argument"); | 2237 ch_error(channel, "received command with non-string argument"); |
2239 if (p_verbose > 2) | 2238 if (p_verbose > 2) |
2240 EMSG(_("E903: received command with non-string argument")); | 2239 emsg(_("E903: received command with non-string argument")); |
2241 return; | 2240 return; |
2242 } | 2241 } |
2243 arg = argv[1].vval.v_string; | 2242 arg = argv[1].vval.v_string; |
2244 if (arg == NULL) | 2243 if (arg == NULL) |
2245 arg = (char_u *)""; | 2244 arg = (char_u *)""; |
2287 if (argv[id_idx].v_type != VAR_UNKNOWN | 2286 if (argv[id_idx].v_type != VAR_UNKNOWN |
2288 && argv[id_idx].v_type != VAR_NUMBER) | 2287 && argv[id_idx].v_type != VAR_NUMBER) |
2289 { | 2288 { |
2290 ch_error(channel, "last argument for expr/call must be a number"); | 2289 ch_error(channel, "last argument for expr/call must be a number"); |
2291 if (p_verbose > 2) | 2290 if (p_verbose > 2) |
2292 EMSG(_("E904: last argument for expr/call must be a number")); | 2291 emsg(_("E904: last argument for expr/call must be a number")); |
2293 } | 2292 } |
2294 else if (is_call && argv[2].v_type != VAR_LIST) | 2293 else if (is_call && argv[2].v_type != VAR_LIST) |
2295 { | 2294 { |
2296 ch_error(channel, "third argument for call must be a list"); | 2295 ch_error(channel, "third argument for call must be a list"); |
2297 if (p_verbose > 2) | 2296 if (p_verbose > 2) |
2298 EMSG(_("E904: third argument for call must be a list")); | 2297 emsg(_("E904: third argument for call must be a list")); |
2299 } | 2298 } |
2300 else | 2299 else |
2301 { | 2300 { |
2302 typval_T *tv = NULL; | 2301 typval_T *tv = NULL; |
2303 typval_T res_tv; | 2302 typval_T res_tv; |
2349 } | 2348 } |
2350 } | 2349 } |
2351 else if (p_verbose > 2) | 2350 else if (p_verbose > 2) |
2352 { | 2351 { |
2353 ch_error(channel, "Received unknown command: %s", (char *)cmd); | 2352 ch_error(channel, "Received unknown command: %s", (char *)cmd); |
2354 EMSG2(_("E905: received unknown command: %s"), cmd); | 2353 semsg(_("E905: received unknown command: %s"), cmd); |
2355 } | 2354 } |
2356 } | 2355 } |
2357 | 2356 |
2358 /* | 2357 /* |
2359 * Invoke the callback at "cbhead". | 2358 * Invoke the callback at "cbhead". |
3767 if (fd == INVALID_FD) | 3766 if (fd == INVALID_FD) |
3768 { | 3767 { |
3769 if (!channel->ch_error && fun != NULL) | 3768 if (!channel->ch_error && fun != NULL) |
3770 { | 3769 { |
3771 ch_error(channel, "%s(): write while not connected", fun); | 3770 ch_error(channel, "%s(): write while not connected", fun); |
3772 EMSG2(_("E630: %s(): write while not connected"), fun); | 3771 semsg(_("E630: %s(): write while not connected"), fun); |
3773 } | 3772 } |
3774 channel->ch_error = TRUE; | 3773 channel->ch_error = TRUE; |
3775 return FAIL; | 3774 return FAIL; |
3776 } | 3775 } |
3777 | 3776 |
3914 else if (res != len) | 3913 else if (res != len) |
3915 { | 3914 { |
3916 if (!channel->ch_error && fun != NULL) | 3915 if (!channel->ch_error && fun != NULL) |
3917 { | 3916 { |
3918 ch_error(channel, "%s(): write failed", fun); | 3917 ch_error(channel, "%s(): write failed", fun); |
3919 EMSG2(_("E631: %s(): write failed"), fun); | 3918 semsg(_("E631: %s(): write failed"), fun); |
3920 } | 3919 } |
3921 channel->ch_error = TRUE; | 3920 channel->ch_error = TRUE; |
3922 return FAIL; | 3921 return FAIL; |
3923 } | 3922 } |
3924 | 3923 |
3962 * allowed. */ | 3961 * allowed. */ |
3963 if (opt->jo_callback != NULL && *opt->jo_callback != NUL) | 3962 if (opt->jo_callback != NULL && *opt->jo_callback != NUL) |
3964 { | 3963 { |
3965 if (eval) | 3964 if (eval) |
3966 { | 3965 { |
3967 EMSG2(_("E917: Cannot use a callback with %s()"), fun); | 3966 semsg(_("E917: Cannot use a callback with %s()"), fun); |
3968 return NULL; | 3967 return NULL; |
3969 } | 3968 } |
3970 channel_set_req_callback(channel, *part_read, | 3969 channel_set_req_callback(channel, *part_read, |
3971 opt->jo_callback, opt->jo_partial, id); | 3970 opt->jo_callback, opt->jo_partial, id); |
3972 } | 3971 } |
4003 part_send = channel_part_send(channel); | 4002 part_send = channel_part_send(channel); |
4004 | 4003 |
4005 ch_mode = channel_get_mode(channel, part_send); | 4004 ch_mode = channel_get_mode(channel, part_send); |
4006 if (ch_mode == MODE_RAW || ch_mode == MODE_NL) | 4005 if (ch_mode == MODE_RAW || ch_mode == MODE_NL) |
4007 { | 4006 { |
4008 EMSG(_("E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel")); | 4007 emsg(_("E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel")); |
4009 return; | 4008 return; |
4010 } | 4009 } |
4011 | 4010 |
4012 id = ++channel->ch_last_msg_id; | 4011 id = ++channel->ch_last_msg_id; |
4013 text = json_encode_nr_expr(id, &argvars[1], | 4012 text = json_encode_nr_expr(id, &argvars[1], |
4476 *modep = MODE_JS; | 4475 *modep = MODE_JS; |
4477 else if (STRCMP(val, "json") == 0) | 4476 else if (STRCMP(val, "json") == 0) |
4478 *modep = MODE_JSON; | 4477 *modep = MODE_JSON; |
4479 else | 4478 else |
4480 { | 4479 { |
4481 EMSG2(_(e_invarg2), val); | 4480 semsg(_(e_invarg2), val); |
4482 return FAIL; | 4481 return FAIL; |
4483 } | 4482 } |
4484 return OK; | 4483 return OK; |
4485 } | 4484 } |
4486 | 4485 |
4500 opt->jo_io[part] = JIO_BUFFER; | 4499 opt->jo_io[part] = JIO_BUFFER; |
4501 else if (STRCMP(val, "out") == 0 && part == PART_ERR) | 4500 else if (STRCMP(val, "out") == 0 && part == PART_ERR) |
4502 opt->jo_io[part] = JIO_OUT; | 4501 opt->jo_io[part] = JIO_OUT; |
4503 else | 4502 else |
4504 { | 4503 { |
4505 EMSG2(_(e_invarg2), val); | 4504 semsg(_(e_invarg2), val); |
4506 return FAIL; | 4505 return FAIL; |
4507 } | 4506 } |
4508 return OK; | 4507 return OK; |
4509 } | 4508 } |
4510 | 4509 |
4574 | 4573 |
4575 if (tv->v_type == VAR_UNKNOWN) | 4574 if (tv->v_type == VAR_UNKNOWN) |
4576 return OK; | 4575 return OK; |
4577 if (tv->v_type != VAR_DICT) | 4576 if (tv->v_type != VAR_DICT) |
4578 { | 4577 { |
4579 EMSG(_(e_dictreq)); | 4578 emsg(_(e_dictreq)); |
4580 return FAIL; | 4579 return FAIL; |
4581 } | 4580 } |
4582 dict = tv->vval.v_dict; | 4581 dict = tv->vval.v_dict; |
4583 if (dict == NULL) | 4582 if (dict == NULL) |
4584 return OK; | 4583 return OK; |
4663 break; | 4662 break; |
4664 opt->jo_set |= JO_OUT_BUF << (part - PART_OUT); | 4663 opt->jo_set |= JO_OUT_BUF << (part - PART_OUT); |
4665 opt->jo_io_buf[part] = tv_get_number(item); | 4664 opt->jo_io_buf[part] = tv_get_number(item); |
4666 if (opt->jo_io_buf[part] <= 0) | 4665 if (opt->jo_io_buf[part] <= 0) |
4667 { | 4666 { |
4668 EMSG3(_(e_invargNval), hi->hi_key, tv_get_string(item)); | 4667 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
4669 return FAIL; | 4668 return FAIL; |
4670 } | 4669 } |
4671 if (buflist_findnr(opt->jo_io_buf[part]) == NULL) | 4670 if (buflist_findnr(opt->jo_io_buf[part]) == NULL) |
4672 { | 4671 { |
4673 EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[part]); | 4672 semsg(_(e_nobufnr), (long)opt->jo_io_buf[part]); |
4674 return FAIL; | 4673 return FAIL; |
4675 } | 4674 } |
4676 } | 4675 } |
4677 else if (STRCMP(hi->hi_key, "out_modifiable") == 0 | 4676 else if (STRCMP(hi->hi_key, "out_modifiable") == 0 |
4678 || STRCMP(hi->hi_key, "err_modifiable") == 0) | 4677 || STRCMP(hi->hi_key, "err_modifiable") == 0) |
4712 opt->jo_set |= JO_IN_BOT; | 4711 opt->jo_set |= JO_IN_BOT; |
4713 } | 4712 } |
4714 *lp = tv_get_number(item); | 4713 *lp = tv_get_number(item); |
4715 if (*lp < 0) | 4714 if (*lp < 0) |
4716 { | 4715 { |
4717 EMSG3(_(e_invargNval), hi->hi_key, tv_get_string(item)); | 4716 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
4718 return FAIL; | 4717 return FAIL; |
4719 } | 4718 } |
4720 } | 4719 } |
4721 else if (STRCMP(hi->hi_key, "channel") == 0) | 4720 else if (STRCMP(hi->hi_key, "channel") == 0) |
4722 { | 4721 { |
4723 if (!(supported & JO_OUT_IO)) | 4722 if (!(supported & JO_OUT_IO)) |
4724 break; | 4723 break; |
4725 opt->jo_set |= JO_CHANNEL; | 4724 opt->jo_set |= JO_CHANNEL; |
4726 if (item->v_type != VAR_CHANNEL) | 4725 if (item->v_type != VAR_CHANNEL) |
4727 { | 4726 { |
4728 EMSG2(_(e_invargval), "channel"); | 4727 semsg(_(e_invargval), "channel"); |
4729 return FAIL; | 4728 return FAIL; |
4730 } | 4729 } |
4731 opt->jo_channel = item->vval.v_channel; | 4730 opt->jo_channel = item->vval.v_channel; |
4732 } | 4731 } |
4733 else if (STRCMP(hi->hi_key, "callback") == 0) | 4732 else if (STRCMP(hi->hi_key, "callback") == 0) |
4736 break; | 4735 break; |
4737 opt->jo_set |= JO_CALLBACK; | 4736 opt->jo_set |= JO_CALLBACK; |
4738 opt->jo_callback = get_callback(item, &opt->jo_partial); | 4737 opt->jo_callback = get_callback(item, &opt->jo_partial); |
4739 if (opt->jo_callback == NULL) | 4738 if (opt->jo_callback == NULL) |
4740 { | 4739 { |
4741 EMSG2(_(e_invargval), "callback"); | 4740 semsg(_(e_invargval), "callback"); |
4742 return FAIL; | 4741 return FAIL; |
4743 } | 4742 } |
4744 } | 4743 } |
4745 else if (STRCMP(hi->hi_key, "out_cb") == 0) | 4744 else if (STRCMP(hi->hi_key, "out_cb") == 0) |
4746 { | 4745 { |
4748 break; | 4747 break; |
4749 opt->jo_set |= JO_OUT_CALLBACK; | 4748 opt->jo_set |= JO_OUT_CALLBACK; |
4750 opt->jo_out_cb = get_callback(item, &opt->jo_out_partial); | 4749 opt->jo_out_cb = get_callback(item, &opt->jo_out_partial); |
4751 if (opt->jo_out_cb == NULL) | 4750 if (opt->jo_out_cb == NULL) |
4752 { | 4751 { |
4753 EMSG2(_(e_invargval), "out_cb"); | 4752 semsg(_(e_invargval), "out_cb"); |
4754 return FAIL; | 4753 return FAIL; |
4755 } | 4754 } |
4756 } | 4755 } |
4757 else if (STRCMP(hi->hi_key, "err_cb") == 0) | 4756 else if (STRCMP(hi->hi_key, "err_cb") == 0) |
4758 { | 4757 { |
4760 break; | 4759 break; |
4761 opt->jo_set |= JO_ERR_CALLBACK; | 4760 opt->jo_set |= JO_ERR_CALLBACK; |
4762 opt->jo_err_cb = get_callback(item, &opt->jo_err_partial); | 4761 opt->jo_err_cb = get_callback(item, &opt->jo_err_partial); |
4763 if (opt->jo_err_cb == NULL) | 4762 if (opt->jo_err_cb == NULL) |
4764 { | 4763 { |
4765 EMSG2(_(e_invargval), "err_cb"); | 4764 semsg(_(e_invargval), "err_cb"); |
4766 return FAIL; | 4765 return FAIL; |
4767 } | 4766 } |
4768 } | 4767 } |
4769 else if (STRCMP(hi->hi_key, "close_cb") == 0) | 4768 else if (STRCMP(hi->hi_key, "close_cb") == 0) |
4770 { | 4769 { |
4772 break; | 4771 break; |
4773 opt->jo_set |= JO_CLOSE_CALLBACK; | 4772 opt->jo_set |= JO_CLOSE_CALLBACK; |
4774 opt->jo_close_cb = get_callback(item, &opt->jo_close_partial); | 4773 opt->jo_close_cb = get_callback(item, &opt->jo_close_partial); |
4775 if (opt->jo_close_cb == NULL) | 4774 if (opt->jo_close_cb == NULL) |
4776 { | 4775 { |
4777 EMSG2(_(e_invargval), "close_cb"); | 4776 semsg(_(e_invargval), "close_cb"); |
4778 return FAIL; | 4777 return FAIL; |
4779 } | 4778 } |
4780 } | 4779 } |
4781 else if (STRCMP(hi->hi_key, "drop") == 0) | 4780 else if (STRCMP(hi->hi_key, "drop") == 0) |
4782 { | 4781 { |
4785 | 4784 |
4786 if (STRCMP(val, "never") == 0) | 4785 if (STRCMP(val, "never") == 0) |
4787 never = TRUE; | 4786 never = TRUE; |
4788 else if (STRCMP(val, "auto") != 0) | 4787 else if (STRCMP(val, "auto") != 0) |
4789 { | 4788 { |
4790 EMSG3(_(e_invargNval), "drop", val); | 4789 semsg(_(e_invargNval), "drop", val); |
4791 return FAIL; | 4790 return FAIL; |
4792 } | 4791 } |
4793 opt->jo_drop_never = never; | 4792 opt->jo_drop_never = never; |
4794 } | 4793 } |
4795 else if (STRCMP(hi->hi_key, "exit_cb") == 0) | 4794 else if (STRCMP(hi->hi_key, "exit_cb") == 0) |
4798 break; | 4797 break; |
4799 opt->jo_set |= JO_EXIT_CB; | 4798 opt->jo_set |= JO_EXIT_CB; |
4800 opt->jo_exit_cb = get_callback(item, &opt->jo_exit_partial); | 4799 opt->jo_exit_cb = get_callback(item, &opt->jo_exit_partial); |
4801 if (opt->jo_exit_cb == NULL) | 4800 if (opt->jo_exit_cb == NULL) |
4802 { | 4801 { |
4803 EMSG2(_(e_invargval), "exit_cb"); | 4802 semsg(_(e_invargval), "exit_cb"); |
4804 return FAIL; | 4803 return FAIL; |
4805 } | 4804 } |
4806 } | 4805 } |
4807 #ifdef FEAT_TERMINAL | 4806 #ifdef FEAT_TERMINAL |
4808 else if (STRCMP(hi->hi_key, "term_name") == 0) | 4807 else if (STRCMP(hi->hi_key, "term_name") == 0) |
4811 break; | 4810 break; |
4812 opt->jo_set2 |= JO2_TERM_NAME; | 4811 opt->jo_set2 |= JO2_TERM_NAME; |
4813 opt->jo_term_name = tv_get_string_chk(item); | 4812 opt->jo_term_name = tv_get_string_chk(item); |
4814 if (opt->jo_term_name == NULL) | 4813 if (opt->jo_term_name == NULL) |
4815 { | 4814 { |
4816 EMSG2(_(e_invargval), "term_name"); | 4815 semsg(_(e_invargval), "term_name"); |
4817 return FAIL; | 4816 return FAIL; |
4818 } | 4817 } |
4819 } | 4818 } |
4820 else if (STRCMP(hi->hi_key, "term_finish") == 0) | 4819 else if (STRCMP(hi->hi_key, "term_finish") == 0) |
4821 { | 4820 { |
4822 if (!(supported2 & JO2_TERM_FINISH)) | 4821 if (!(supported2 & JO2_TERM_FINISH)) |
4823 break; | 4822 break; |
4824 val = tv_get_string(item); | 4823 val = tv_get_string(item); |
4825 if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0) | 4824 if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0) |
4826 { | 4825 { |
4827 EMSG3(_(e_invargNval), "term_finish", val); | 4826 semsg(_(e_invargNval), "term_finish", val); |
4828 return FAIL; | 4827 return FAIL; |
4829 } | 4828 } |
4830 opt->jo_set2 |= JO2_TERM_FINISH; | 4829 opt->jo_set2 |= JO2_TERM_FINISH; |
4831 opt->jo_term_finish = *val; | 4830 opt->jo_term_finish = *val; |
4832 } | 4831 } |
4846 || vim_strchr(p + 2, '%') != NULL)) | 4845 || vim_strchr(p + 2, '%') != NULL)) |
4847 p = NULL; | 4846 p = NULL; |
4848 } | 4847 } |
4849 if (p == NULL) | 4848 if (p == NULL) |
4850 { | 4849 { |
4851 EMSG2(_(e_invargval), "term_opencmd"); | 4850 semsg(_(e_invargval), "term_opencmd"); |
4852 return FAIL; | 4851 return FAIL; |
4853 } | 4852 } |
4854 } | 4853 } |
4855 else if (STRCMP(hi->hi_key, "eof_chars") == 0) | 4854 else if (STRCMP(hi->hi_key, "eof_chars") == 0) |
4856 { | 4855 { |
4860 break; | 4859 break; |
4861 opt->jo_set2 |= JO2_EOF_CHARS; | 4860 opt->jo_set2 |= JO2_EOF_CHARS; |
4862 p = opt->jo_eof_chars = tv_get_string_chk(item); | 4861 p = opt->jo_eof_chars = tv_get_string_chk(item); |
4863 if (p == NULL) | 4862 if (p == NULL) |
4864 { | 4863 { |
4865 EMSG2(_(e_invargval), "eof_chars"); | 4864 semsg(_(e_invargval), "eof_chars"); |
4866 return FAIL; | 4865 return FAIL; |
4867 } | 4866 } |
4868 } | 4867 } |
4869 else if (STRCMP(hi->hi_key, "term_rows") == 0) | 4868 else if (STRCMP(hi->hi_key, "term_rows") == 0) |
4870 { | 4869 { |
4926 break; | 4925 break; |
4927 | 4926 |
4928 if (item == NULL || item->v_type != VAR_LIST | 4927 if (item == NULL || item->v_type != VAR_LIST |
4929 || item->vval.v_list == NULL) | 4928 || item->vval.v_list == NULL) |
4930 { | 4929 { |
4931 EMSG2(_(e_invargval), "ansi_colors"); | 4930 semsg(_(e_invargval), "ansi_colors"); |
4932 return FAIL; | 4931 return FAIL; |
4933 } | 4932 } |
4934 | 4933 |
4935 li = item->vval.v_list->lv_first; | 4934 li = item->vval.v_list->lv_first; |
4936 for (; li != NULL && n < 16; li = li->li_next, n++) | 4935 for (; li != NULL && n < 16; li = li->li_next, n++) |
4949 rgb[n] = GUI_MCH_GET_RGB(guicolor); | 4948 rgb[n] = GUI_MCH_GET_RGB(guicolor); |
4950 } | 4949 } |
4951 | 4950 |
4952 if (n != 16 || li != NULL) | 4951 if (n != 16 || li != NULL) |
4953 { | 4952 { |
4954 EMSG2(_(e_invargval), "ansi_colors"); | 4953 semsg(_(e_invargval), "ansi_colors"); |
4955 return FAIL; | 4954 return FAIL; |
4956 } | 4955 } |
4957 | 4956 |
4958 opt->jo_set2 |= JO2_ANSI_COLORS; | 4957 opt->jo_set2 |= JO2_ANSI_COLORS; |
4959 memcpy(opt->jo_ansi_colors, rgb, sizeof(rgb)); | 4958 memcpy(opt->jo_ansi_colors, rgb, sizeof(rgb)); |
4964 { | 4963 { |
4965 if (!(supported2 & JO2_ENV)) | 4964 if (!(supported2 & JO2_ENV)) |
4966 break; | 4965 break; |
4967 if (item->v_type != VAR_DICT) | 4966 if (item->v_type != VAR_DICT) |
4968 { | 4967 { |
4969 EMSG2(_(e_invargval), "env"); | 4968 semsg(_(e_invargval), "env"); |
4970 return FAIL; | 4969 return FAIL; |
4971 } | 4970 } |
4972 opt->jo_set2 |= JO2_ENV; | 4971 opt->jo_set2 |= JO2_ENV; |
4973 opt->jo_env = item->vval.v_dict; | 4972 opt->jo_env = item->vval.v_dict; |
4974 if (opt->jo_env != NULL) | 4973 if (opt->jo_env != NULL) |
4983 #ifndef WIN32 // Win32 directories don't have the concept of "executable" | 4982 #ifndef WIN32 // Win32 directories don't have the concept of "executable" |
4984 || mch_access((char *)opt->jo_cwd, X_OK) != 0 | 4983 || mch_access((char *)opt->jo_cwd, X_OK) != 0 |
4985 #endif | 4984 #endif |
4986 ) | 4985 ) |
4987 { | 4986 { |
4988 EMSG2(_(e_invargval), "cwd"); | 4987 semsg(_(e_invargval), "cwd"); |
4989 return FAIL; | 4988 return FAIL; |
4990 } | 4989 } |
4991 opt->jo_set2 |= JO2_CWD; | 4990 opt->jo_set2 |= JO2_CWD; |
4992 } | 4991 } |
4993 else if (STRCMP(hi->hi_key, "waittime") == 0) | 4992 else if (STRCMP(hi->hi_key, "waittime") == 0) |
5028 opt->jo_part = PART_ERR; | 5027 opt->jo_part = PART_ERR; |
5029 else if (STRCMP(val, "out") == 0) | 5028 else if (STRCMP(val, "out") == 0) |
5030 opt->jo_part = PART_OUT; | 5029 opt->jo_part = PART_OUT; |
5031 else | 5030 else |
5032 { | 5031 { |
5033 EMSG3(_(e_invargNval), "part", val); | 5032 semsg(_(e_invargNval), "part", val); |
5034 return FAIL; | 5033 return FAIL; |
5035 } | 5034 } |
5036 } | 5035 } |
5037 else if (STRCMP(hi->hi_key, "id") == 0) | 5036 else if (STRCMP(hi->hi_key, "id") == 0) |
5038 { | 5037 { |
5048 opt->jo_set |= JO_STOPONEXIT; | 5047 opt->jo_set |= JO_STOPONEXIT; |
5049 opt->jo_stoponexit = tv_get_string_buf_chk(item, | 5048 opt->jo_stoponexit = tv_get_string_buf_chk(item, |
5050 opt->jo_soe_buf); | 5049 opt->jo_soe_buf); |
5051 if (opt->jo_stoponexit == NULL) | 5050 if (opt->jo_stoponexit == NULL) |
5052 { | 5051 { |
5053 EMSG2(_(e_invargval), "stoponexit"); | 5052 semsg(_(e_invargval), "stoponexit"); |
5054 return FAIL; | 5053 return FAIL; |
5055 } | 5054 } |
5056 } | 5055 } |
5057 else if (STRCMP(hi->hi_key, "block_write") == 0) | 5056 else if (STRCMP(hi->hi_key, "block_write") == 0) |
5058 { | 5057 { |
5065 break; | 5064 break; |
5066 --todo; | 5065 --todo; |
5067 } | 5066 } |
5068 if (todo > 0) | 5067 if (todo > 0) |
5069 { | 5068 { |
5070 EMSG2(_(e_invarg2), hi->hi_key); | 5069 semsg(_(e_invarg2), hi->hi_key); |
5071 return FAIL; | 5070 return FAIL; |
5072 } | 5071 } |
5073 | 5072 |
5074 return OK; | 5073 return OK; |
5075 } | 5074 } |
5096 { | 5095 { |
5097 channel = tv->vval.v_channel; | 5096 channel = tv->vval.v_channel; |
5098 } | 5097 } |
5099 else | 5098 else |
5100 { | 5099 { |
5101 EMSG2(_(e_invarg2), tv_get_string(tv)); | 5100 semsg(_(e_invarg2), tv_get_string(tv)); |
5102 return NULL; | 5101 return NULL; |
5103 } | 5102 } |
5104 if (channel != NULL && reading) | 5103 if (channel != NULL && reading) |
5105 has_readahead = channel_has_readahead(channel, | 5104 has_readahead = channel_has_readahead(channel, |
5106 part != PART_COUNT ? part : channel_part_read(channel)); | 5105 part != PART_COUNT ? part : channel_part_read(channel)); |
5107 | 5106 |
5108 if (check_open && (channel == NULL || (!channel_is_open(channel) | 5107 if (check_open && (channel == NULL || (!channel_is_open(channel) |
5109 && !(reading && has_readahead)))) | 5108 && !(reading && has_readahead)))) |
5110 { | 5109 { |
5111 EMSG(_("E906: not an open channel")); | 5110 emsg(_("E906: not an open channel")); |
5112 return NULL; | 5111 return NULL; |
5113 } | 5112 } |
5114 return channel; | 5113 return channel; |
5115 } | 5114 } |
5116 | 5115 |
5660 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) | 5659 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) |
5661 && opt.jo_io[part] == JIO_FILE | 5660 && opt.jo_io[part] == JIO_FILE |
5662 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) | 5661 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) |
5663 || *opt.jo_io_name[part] == NUL)) | 5662 || *opt.jo_io_name[part] == NUL)) |
5664 { | 5663 { |
5665 EMSG(_("E920: _io file requires _name to be set")); | 5664 emsg(_("E920: _io file requires _name to be set")); |
5666 goto theend; | 5665 goto theend; |
5667 } | 5666 } |
5668 | 5667 |
5669 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) | 5668 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) |
5670 { | 5669 { |
5673 /* check that we can find the buffer before starting the job */ | 5672 /* check that we can find the buffer before starting the job */ |
5674 if (opt.jo_set & JO_IN_BUF) | 5673 if (opt.jo_set & JO_IN_BUF) |
5675 { | 5674 { |
5676 buf = buflist_findnr(opt.jo_io_buf[PART_IN]); | 5675 buf = buflist_findnr(opt.jo_io_buf[PART_IN]); |
5677 if (buf == NULL) | 5676 if (buf == NULL) |
5678 EMSGN(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); | 5677 semsg(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); |
5679 } | 5678 } |
5680 else if (!(opt.jo_set & JO_IN_NAME)) | 5679 else if (!(opt.jo_set & JO_IN_NAME)) |
5681 { | 5680 { |
5682 EMSG(_("E915: in_io buffer requires in_buf or in_name to be set")); | 5681 emsg(_("E915: in_io buffer requires in_buf or in_name to be set")); |
5683 } | 5682 } |
5684 else | 5683 else |
5685 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); | 5684 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); |
5686 if (buf == NULL) | 5685 if (buf == NULL) |
5687 goto theend; | 5686 goto theend; |
5695 sprintf((char *)numbuf, "%d", opt.jo_io_buf[PART_IN]); | 5694 sprintf((char *)numbuf, "%d", opt.jo_io_buf[PART_IN]); |
5696 s = numbuf; | 5695 s = numbuf; |
5697 } | 5696 } |
5698 else | 5697 else |
5699 s = opt.jo_io_name[PART_IN]; | 5698 s = opt.jo_io_name[PART_IN]; |
5700 EMSG2(_("E918: buffer must be loaded: %s"), s); | 5699 semsg(_("E918: buffer must be loaded: %s"), s); |
5701 goto theend; | 5700 goto theend; |
5702 } | 5701 } |
5703 job->jv_in_buf = buf; | 5702 job->jv_in_buf = buf; |
5704 } | 5703 } |
5705 | 5704 |
5724 { | 5723 { |
5725 /* Command is a string. */ | 5724 /* Command is a string. */ |
5726 cmd = argvars[0].vval.v_string; | 5725 cmd = argvars[0].vval.v_string; |
5727 if (cmd == NULL || *cmd == NUL) | 5726 if (cmd == NULL || *cmd == NUL) |
5728 { | 5727 { |
5729 EMSG(_(e_invarg)); | 5728 emsg(_(e_invarg)); |
5730 goto theend; | 5729 goto theend; |
5731 } | 5730 } |
5732 | 5731 |
5733 if (build_argv_from_string(cmd, &argv, &argc) == FAIL) | 5732 if (build_argv_from_string(cmd, &argv, &argc) == FAIL) |
5734 goto theend; | 5733 goto theend; |
5735 } | 5734 } |
5736 else if (argvars[0].v_type != VAR_LIST | 5735 else if (argvars[0].v_type != VAR_LIST |
5737 || argvars[0].vval.v_list == NULL | 5736 || argvars[0].vval.v_list == NULL |
5738 || argvars[0].vval.v_list->lv_len < 1) | 5737 || argvars[0].vval.v_list->lv_len < 1) |
5739 { | 5738 { |
5740 EMSG(_(e_invarg)); | 5739 emsg(_(e_invarg)); |
5741 goto theend; | 5740 goto theend; |
5742 } | 5741 } |
5743 else | 5742 else |
5744 { | 5743 { |
5745 list_T *l = argvars[0].vval.v_list; | 5744 list_T *l = argvars[0].vval.v_list; |
5896 else | 5895 else |
5897 { | 5896 { |
5898 arg = tv_get_string_chk(&argvars[1]); | 5897 arg = tv_get_string_chk(&argvars[1]); |
5899 if (arg == NULL) | 5898 if (arg == NULL) |
5900 { | 5899 { |
5901 EMSG(_(e_invarg)); | 5900 emsg(_(e_invarg)); |
5902 return 0; | 5901 return 0; |
5903 } | 5902 } |
5904 } | 5903 } |
5905 if (job->jv_status == JOB_FAILED) | 5904 if (job->jv_status == JOB_FAILED) |
5906 { | 5905 { |