comparison src/evalfunc.c @ 32685:3868e8035b8c v9.0.1673

patch 9.0.1673: cannot produce a status 418 or 503 message Commit: https://github.com/vim/vim/commit/80adaa8ae8398403ca4e9797219ea9a501fc76a5 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 7 18:57:40 2023 +0100 patch 9.0.1673: cannot produce a status 418 or 503 message Problem: Cannot produce a status 418 or 503 message. Solution: Add err_teapot().
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 Jul 2023 20:00:05 +0200
parents 695b50472e85
children 257ab4ee8e4a
comparison
equal deleted inserted replaced
32684:fa275d713294 32685:3868e8035b8c
43 static void f_deepcopy(typval_T *argvars, typval_T *rettv); 43 static void f_deepcopy(typval_T *argvars, typval_T *rettv);
44 static void f_did_filetype(typval_T *argvars, typval_T *rettv); 44 static void f_did_filetype(typval_T *argvars, typval_T *rettv);
45 static void f_echoraw(typval_T *argvars, typval_T *rettv); 45 static void f_echoraw(typval_T *argvars, typval_T *rettv);
46 static void f_empty(typval_T *argvars, typval_T *rettv); 46 static void f_empty(typval_T *argvars, typval_T *rettv);
47 static void f_environ(typval_T *argvars, typval_T *rettv); 47 static void f_environ(typval_T *argvars, typval_T *rettv);
48 static void f_err_teapot(typval_T *argvars, typval_T *rettv);
48 static void f_escape(typval_T *argvars, typval_T *rettv); 49 static void f_escape(typval_T *argvars, typval_T *rettv);
49 static void f_eval(typval_T *argvars, typval_T *rettv); 50 static void f_eval(typval_T *argvars, typval_T *rettv);
50 static void f_eventhandler(typval_T *argvars, typval_T *rettv); 51 static void f_eventhandler(typval_T *argvars, typval_T *rettv);
51 static void f_execute(typval_T *argvars, typval_T *rettv); 52 static void f_execute(typval_T *argvars, typval_T *rettv);
52 static void f_exists_compiled(typval_T *argvars, typval_T *rettv); 53 static void f_exists_compiled(typval_T *argvars, typval_T *rettv);
1879 ret_void, f_echoraw}, 1880 ret_void, f_echoraw},
1880 {"empty", 1, 1, FEARG_1, NULL, 1881 {"empty", 1, 1, FEARG_1, NULL,
1881 ret_number_bool, f_empty}, 1882 ret_number_bool, f_empty},
1882 {"environ", 0, 0, 0, NULL, 1883 {"environ", 0, 0, 0, NULL,
1883 ret_dict_string, f_environ}, 1884 ret_dict_string, f_environ},
1885 {"err_teapot", 0, 1, 0, NULL,
1886 ret_number_bool, f_err_teapot},
1884 {"escape", 2, 2, FEARG_1, arg2_string, 1887 {"escape", 2, 2, FEARG_1, arg2_string,
1885 ret_string, f_escape}, 1888 ret_string, f_escape},
1886 {"eval", 1, 1, FEARG_1, arg1_string, 1889 {"eval", 1, 1, FEARG_1, arg1_string,
1887 ret_any, f_eval}, 1890 ret_any, f_eval},
1888 {"eventhandler", 0, 0, 0, NULL, 1891 {"eventhandler", 0, 0, 0, NULL,
3921 } 3924 }
3922 #endif 3925 #endif
3923 } 3926 }
3924 3927
3925 /* 3928 /*
3929 * "err_teapot()" function
3930 */
3931 static void
3932 f_err_teapot(typval_T *argvars, typval_T *rettv UNUSED)
3933 {
3934 if (argvars[0].v_type != VAR_UNKNOWN)
3935 {
3936 if (argvars[0].v_type == VAR_STRING)
3937 {
3938 char_u *s = tv_get_string_strict(&argvars[0]);
3939 if (s == NULL || *skipwhite(s) == NUL)
3940 return;
3941 }
3942
3943 int err = FALSE;
3944 int do_503 = eval_expr_to_bool(&argvars[0], &err);
3945 if (!err && do_503)
3946 {
3947 emsg(_(e_coffee_currently_not_available));
3948 return;
3949 }
3950 }
3951
3952 emsg(_(e_im_a_teapot));
3953 }
3954
3955 /*
3926 * "escape({string}, {chars})" function 3956 * "escape({string}, {chars})" function
3927 */ 3957 */
3928 static void 3958 static void
3929 f_escape(typval_T *argvars, typval_T *rettv) 3959 f_escape(typval_T *argvars, typval_T *rettv)
3930 { 3960 {
6456 1 6486 1
6457 #else 6487 #else
6458 0 6488 0
6459 #endif 6489 #endif
6460 }, 6490 },
6491 {":tearoff",
6492 // same #ifdef as used for ex_tearoff().
6493 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF)
6494 1
6495 #else
6496 0
6497 #endif
6498 },
6461 {NULL, 0} 6499 {NULL, 0}
6462 }; 6500 };
6463 6501
6464 if (in_vim9script() 6502 if (in_vim9script()
6465 && (check_for_string_arg(argvars, 0) == FAIL 6503 && (check_for_string_arg(argvars, 0) == FAIL