mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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().
This commit is contained in:
@@ -154,6 +154,7 @@ digraph_getlist([{listall}]) List get all |digraph|s
|
|||||||
digraph_set({chars}, {digraph}) Boolean register |digraph|
|
digraph_set({chars}, {digraph}) Boolean register |digraph|
|
||||||
digraph_setlist({digraphlist}) Boolean register multiple |digraph|s
|
digraph_setlist({digraphlist}) Boolean register multiple |digraph|s
|
||||||
echoraw({expr}) none output {expr} as-is
|
echoraw({expr}) none output {expr} as-is
|
||||||
|
err_teapot() Number produce error 418
|
||||||
empty({expr}) Number |TRUE| if {expr} is empty
|
empty({expr}) Number |TRUE| if {expr} is empty
|
||||||
environ() Dict return environment variables
|
environ() Dict return environment variables
|
||||||
escape({string}, {chars}) String escape {chars} in {string} with '\'
|
escape({string}, {chars}) String escape {chars} in {string} with '\'
|
||||||
@@ -2176,6 +2177,14 @@ echoraw({string}) *echoraw()*
|
|||||||
< Use with care, you can mess up the terminal this way.
|
< Use with care, you can mess up the terminal this way.
|
||||||
|
|
||||||
|
|
||||||
|
err_teapot([{expr}]) *err_teapot()*
|
||||||
|
Produce an error with number 418, needed for implementation of
|
||||||
|
RFC 2325.
|
||||||
|
If {expr} is present and it is TRUE error 503 is given,
|
||||||
|
indicating that coffee is temporarily not available.
|
||||||
|
If {expr} is present it must be a String.
|
||||||
|
|
||||||
|
|
||||||
empty({expr}) *empty()*
|
empty({expr}) *empty()*
|
||||||
Return the Number 1 if {expr} is empty, zero otherwise.
|
Return the Number 1 if {expr} is empty, zero otherwise.
|
||||||
- A |List| or |Dictionary| is empty when it does not have any
|
- A |List| or |Dictionary| is empty when it does not have any
|
||||||
|
@@ -1037,6 +1037,8 @@ EXTERN char e_missing_argument_str[]
|
|||||||
INIT(= N_("E417: Missing argument: %s"));
|
INIT(= N_("E417: Missing argument: %s"));
|
||||||
EXTERN char e_illegal_value_str[]
|
EXTERN char e_illegal_value_str[]
|
||||||
INIT(= N_("E418: Illegal value: %s"));
|
INIT(= N_("E418: Illegal value: %s"));
|
||||||
|
EXTERN char e_im_a_teapot[]
|
||||||
|
INIT(= N_("E418: I'm a teapot"));
|
||||||
EXTERN char e_fg_color_unknown[]
|
EXTERN char e_fg_color_unknown[]
|
||||||
INIT(= N_("E419: FG color unknown"));
|
INIT(= N_("E419: FG color unknown"));
|
||||||
EXTERN char e_bg_color_unknown[]
|
EXTERN char e_bg_color_unknown[]
|
||||||
@@ -1270,6 +1272,8 @@ EXTERN char e_is_not_file_or_writable_device[]
|
|||||||
INIT(= N_("is not a file or writable device"));
|
INIT(= N_("is not a file or writable device"));
|
||||||
EXTERN char e_str_is_not_file_or_writable_device[]
|
EXTERN char e_str_is_not_file_or_writable_device[]
|
||||||
INIT(= N_("E503: \"%s\" is not a file or writable device"));
|
INIT(= N_("E503: \"%s\" is not a file or writable device"));
|
||||||
|
EXTERN char e_coffee_currently_not_available[]
|
||||||
|
INIT(= N_("E503: Coffee is currently not available"));
|
||||||
// E504
|
// E504
|
||||||
EXTERN char e_is_read_only_cannot_override_W_in_cpoptions[]
|
EXTERN char e_is_read_only_cannot_override_W_in_cpoptions[]
|
||||||
INIT(= N_("is read-only (cannot override: \"W\" in 'cpoptions')"));
|
INIT(= N_("is read-only (cannot override: \"W\" in 'cpoptions')"));
|
||||||
|
@@ -45,6 +45,7 @@ static void f_did_filetype(typval_T *argvars, typval_T *rettv);
|
|||||||
static void f_echoraw(typval_T *argvars, typval_T *rettv);
|
static void f_echoraw(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_empty(typval_T *argvars, typval_T *rettv);
|
static void f_empty(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_environ(typval_T *argvars, typval_T *rettv);
|
static void f_environ(typval_T *argvars, typval_T *rettv);
|
||||||
|
static void f_err_teapot(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_escape(typval_T *argvars, typval_T *rettv);
|
static void f_escape(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_eval(typval_T *argvars, typval_T *rettv);
|
static void f_eval(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_eventhandler(typval_T *argvars, typval_T *rettv);
|
static void f_eventhandler(typval_T *argvars, typval_T *rettv);
|
||||||
@@ -1881,6 +1882,8 @@ static funcentry_T global_functions[] =
|
|||||||
ret_number_bool, f_empty},
|
ret_number_bool, f_empty},
|
||||||
{"environ", 0, 0, 0, NULL,
|
{"environ", 0, 0, 0, NULL,
|
||||||
ret_dict_string, f_environ},
|
ret_dict_string, f_environ},
|
||||||
|
{"err_teapot", 0, 1, 0, NULL,
|
||||||
|
ret_number_bool, f_err_teapot},
|
||||||
{"escape", 2, 2, FEARG_1, arg2_string,
|
{"escape", 2, 2, FEARG_1, arg2_string,
|
||||||
ret_string, f_escape},
|
ret_string, f_escape},
|
||||||
{"eval", 1, 1, FEARG_1, arg1_string,
|
{"eval", 1, 1, FEARG_1, arg1_string,
|
||||||
@@ -3922,6 +3925,33 @@ f_environ(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "err_teapot()" function
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
f_err_teapot(typval_T *argvars, typval_T *rettv UNUSED)
|
||||||
|
{
|
||||||
|
if (argvars[0].v_type != VAR_UNKNOWN)
|
||||||
|
{
|
||||||
|
if (argvars[0].v_type == VAR_STRING)
|
||||||
|
{
|
||||||
|
char_u *s = tv_get_string_strict(&argvars[0]);
|
||||||
|
if (s == NULL || *skipwhite(s) == NUL)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int err = FALSE;
|
||||||
|
int do_503 = eval_expr_to_bool(&argvars[0], &err);
|
||||||
|
if (!err && do_503)
|
||||||
|
{
|
||||||
|
emsg(_(e_coffee_currently_not_available));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emsg(_(e_im_a_teapot));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "escape({string}, {chars})" function
|
* "escape({string}, {chars})" function
|
||||||
*/
|
*/
|
||||||
@@ -6456,6 +6486,14 @@ f_has(typval_T *argvars, typval_T *rettv)
|
|||||||
1
|
1
|
||||||
#else
|
#else
|
||||||
0
|
0
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
{":tearoff",
|
||||||
|
// same #ifdef as used for ex_tearoff().
|
||||||
|
#if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF)
|
||||||
|
1
|
||||||
|
#else
|
||||||
|
0
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
|
@@ -30,10 +30,13 @@ func Test_has()
|
|||||||
call assert_equal(1, or(has('ttyin'), 1))
|
call assert_equal(1, or(has('ttyin'), 1))
|
||||||
call assert_equal(0, and(has('ttyout'), 0))
|
call assert_equal(0, and(has('ttyout'), 0))
|
||||||
call assert_equal(1, has('multi_byte_encoding'))
|
call assert_equal(1, has('multi_byte_encoding'))
|
||||||
|
call assert_equal(0, has(':tearoff'))
|
||||||
endif
|
endif
|
||||||
call assert_equal(1, has('vcon', 1))
|
call assert_equal(1, has('vcon', 1))
|
||||||
call assert_equal(1, has('mouse_gpm_enabled', 1))
|
call assert_equal(1, has('mouse_gpm_enabled', 1))
|
||||||
|
|
||||||
|
call assert_equal(has('gui_win32') && has('menu'), has(':tearoff'))
|
||||||
|
|
||||||
call assert_equal(0, has('nonexistent'))
|
call assert_equal(0, has('nonexistent'))
|
||||||
call assert_equal(0, has('nonexistent', 1))
|
call assert_equal(0, has('nonexistent', 1))
|
||||||
|
|
||||||
@@ -86,6 +89,17 @@ func Test_empty()
|
|||||||
call assert_fails("call empty(test_unknown())", ['E340:', 'E685:'])
|
call assert_fails("call empty(test_unknown())", ['E340:', 'E685:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_err_teapot()
|
||||||
|
call assert_fails('call err_teapot()', "E418: I'm a teapot")
|
||||||
|
call assert_fails('call err_teapot(0)', "E418: I'm a teapot")
|
||||||
|
call assert_fails('call err_teapot(v:false)', "E418: I'm a teapot")
|
||||||
|
|
||||||
|
call assert_fails('call err_teapot("1")', "E503: Coffee is currently not available")
|
||||||
|
call assert_fails('call err_teapot(v:true)', "E503: Coffee is currently not available")
|
||||||
|
let expr = 1
|
||||||
|
call assert_fails('call err_teapot(expr)', "E503: Coffee is currently not available")
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_test_void()
|
func Test_test_void()
|
||||||
call assert_fails('echo 1 == test_void()', 'E1031:')
|
call assert_fails('echo 1 == test_void()', 'E1031:')
|
||||||
call assert_fails('echo 1.0 == test_void()', 'E1031:')
|
call assert_fails('echo 1.0 == test_void()', 'E1031:')
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1673,
|
||||||
/**/
|
/**/
|
||||||
1672,
|
1672,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user