mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.1.0560: bindtextdomain() does not indicate an error
Problem: bindtextdomain() does not indicate an error (after v9.1.509) Solution: return false on failure (OOM). (Chris van Willegen) closes: #15116 Signed-off-by: Christ van Willegen <cvwillegen@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
965091001f
commit
8252ef134f
@@ -68,7 +68,7 @@ balloon_gettext() String current text in the balloon
|
|||||||
balloon_show({expr}) none show {expr} inside the balloon
|
balloon_show({expr}) none show {expr} inside the balloon
|
||||||
balloon_split({msg}) List split {msg} as used for a balloon
|
balloon_split({msg}) List split {msg} as used for a balloon
|
||||||
bindtextdomain({package}, {path})
|
bindtextdomain({package}, {path})
|
||||||
none bind text domain to specied path
|
Bool bind text domain to specified path
|
||||||
blob2list({blob}) List convert {blob} into a list of numbers
|
blob2list({blob}) List convert {blob} into a list of numbers
|
||||||
browse({save}, {title}, {initdir}, {default})
|
browse({save}, {title}, {initdir}, {default})
|
||||||
String put up a file requester
|
String put up a file requester
|
||||||
@@ -1228,7 +1228,10 @@ bindtextdomain({package}, {path}) *bindtextdomain()*
|
|||||||
translations for a package. {path} is the directory name
|
translations for a package. {path} is the directory name
|
||||||
for the translations. See |package-translation|.
|
for the translations. See |package-translation|.
|
||||||
|
|
||||||
Return type: none
|
Returns v:true on success and v:false on failure (out of
|
||||||
|
memory).
|
||||||
|
|
||||||
|
Return type: |vim9-boolean|
|
||||||
|
|
||||||
blob2list({blob}) *blob2list()*
|
blob2list({blob}) *blob2list()*
|
||||||
Return a List containing the number value of each byte in Blob
|
Return a List containing the number value of each byte in Blob
|
||||||
|
@@ -1827,7 +1827,7 @@ static funcentry_T global_functions[] =
|
|||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
{"bindtextdomain", 2, 2, 0, arg2_string,
|
{"bindtextdomain", 2, 2, 0, arg2_string,
|
||||||
ret_void, f_bindtextdomain},
|
ret_bool, f_bindtextdomain},
|
||||||
{"blob2list", 1, 1, FEARG_1, arg1_blob,
|
{"blob2list", 1, 1, FEARG_1, arg1_blob,
|
||||||
ret_list_number, f_blob2list},
|
ret_list_number, f_blob2list},
|
||||||
{"browse", 4, 4, 0, arg4_browse,
|
{"browse", 4, 4, 0, arg4_browse,
|
||||||
@@ -3486,8 +3486,11 @@ get_buf_arg(typval_T *arg)
|
|||||||
* "bindtextdomain(package, path)" function
|
* "bindtextdomain(package, path)" function
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
f_bindtextdomain(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
f_bindtextdomain(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
|
rettv->v_type = VAR_BOOL;
|
||||||
|
rettv->vval.v_number = VVAL_TRUE;
|
||||||
|
|
||||||
if (check_for_nonempty_string_arg(argvars, 0) == FAIL
|
if (check_for_nonempty_string_arg(argvars, 0) == FAIL
|
||||||
|| check_for_nonempty_string_arg(argvars, 1) == FAIL)
|
|| check_for_nonempty_string_arg(argvars, 1) == FAIL)
|
||||||
return;
|
return;
|
||||||
@@ -3495,7 +3498,13 @@ f_bindtextdomain(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
|||||||
if (strcmp((const char *)argvars[0].vval.v_string, VIMPACKAGE) == 0)
|
if (strcmp((const char *)argvars[0].vval.v_string, VIMPACKAGE) == 0)
|
||||||
semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0]));
|
semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0]));
|
||||||
else
|
else
|
||||||
bindtextdomain((const char *)argvars[0].vval.v_string, (const char *)argvars[1].vval.v_string);
|
{
|
||||||
|
if (bindtextdomain((const char *)argvars[0].vval.v_string, (const char *)argvars[1].vval.v_string) == NULL)
|
||||||
|
{
|
||||||
|
do_outofmem_msg((long)0);
|
||||||
|
rettv->vval.v_number = VVAL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
source check.vim
|
source check.vim
|
||||||
|
|
||||||
|
CheckFeature gettext
|
||||||
|
|
||||||
" Test for gettext()
|
" Test for gettext()
|
||||||
func Test_gettext()
|
func Test_gettext()
|
||||||
call assert_fails('call bindtextdomain("test")', 'E119:')
|
call assert_fails('call bindtextdomain("test")', 'E119:')
|
||||||
|
@@ -2,23 +2,33 @@ source check.vim
|
|||||||
" This fail on CI MacOS 14 because bindtextdomain() is not available there
|
" This fail on CI MacOS 14 because bindtextdomain() is not available there
|
||||||
" (missing library?)
|
" (missing library?)
|
||||||
CheckNotMac
|
CheckNotMac
|
||||||
|
CheckFeature gettext
|
||||||
|
|
||||||
" Test for gettext()
|
" Test for gettext()
|
||||||
func Test_gettext()
|
func Test_gettext()
|
||||||
set encoding=cp1251
|
set encoding=cp1251
|
||||||
call bindtextdomain("__PACKAGE__", getcwd())
|
call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
|
||||||
|
|
||||||
|
try
|
||||||
|
call assert_true(bindtextdomain("__PACKAGE__", getcwd()))
|
||||||
|
|
||||||
try
|
try
|
||||||
language messages ru_RU
|
language messages ru_RU
|
||||||
call assert_equal('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ', gettext("ERROR: ", "__PACKAGE__"))
|
call assert_equal('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ', gettext("ERROR: ", "__PACKAGE__"))
|
||||||
catch /^Vim\%((\a\+)\)\=:E197:/
|
catch /^Vim\%((\a\+)\)\=:E197:/
|
||||||
throw "Skipped: not possible to set locale to ru (missing?)"
|
throw "Skipped: not possible to set locale to ru (missing?)"
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
try
|
try
|
||||||
language messages en_GB.UTF-8
|
language messages en_GB.UTF-8
|
||||||
call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
|
call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
|
||||||
catch /^Vim\%((\a\+)\)\=:E197:/
|
catch /^Vim\%((\a\+)\)\=:E197:/
|
||||||
throw "Skipped: not possible to set locale to en (missing?)"
|
throw "Skipped: not possible to set locale to en (missing?)"
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E342:/
|
||||||
|
throw "Skipped: out of memory executing bindtextdomain()"
|
||||||
|
endtry
|
||||||
set encoding&
|
set encoding&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -2,23 +2,33 @@ source check.vim
|
|||||||
" This fail on CI MacOS 14 because bindtextdomain() is not available there
|
" This fail on CI MacOS 14 because bindtextdomain() is not available there
|
||||||
" (missing library?)
|
" (missing library?)
|
||||||
CheckNotMac
|
CheckNotMac
|
||||||
|
CheckFeature gettext
|
||||||
|
|
||||||
" Test for gettext()
|
" Test for gettext()
|
||||||
func Test_gettext()
|
func Test_gettext()
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
call bindtextdomain("__PACKAGE__", getcwd())
|
call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
|
||||||
|
|
||||||
|
try
|
||||||
|
call assert_true(bindtextdomain("__PACKAGE__", getcwd()))
|
||||||
|
|
||||||
try
|
try
|
||||||
language messages ru_RU
|
language messages ru_RU
|
||||||
call assert_equal('ОШИБКА: ', gettext("ERROR: ", "__PACKAGE__"))
|
call assert_equal('ОШИБКА: ', gettext("ERROR: ", "__PACKAGE__"))
|
||||||
catch /^Vim\%((\a\+)\)\=:E197:/
|
catch /^Vim\%((\a\+)\)\=:E197:/
|
||||||
throw "Skipped: not possible to set locale to ru (missing?)"
|
throw "Skipped: not possible to set locale to ru (missing?)"
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
try
|
try
|
||||||
language messages en_GB.UTF-8
|
language messages en_GB.UTF-8
|
||||||
call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
|
call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
|
||||||
catch /^Vim\%((\a\+)\)\=:E197:/
|
catch /^Vim\%((\a\+)\)\=:E197:/
|
||||||
throw "Skipped: not possible to set locale to en (missing?)"
|
throw "Skipped: not possible to set locale to en (missing?)"
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E342:/
|
||||||
|
throw "Skipped: out of memory executing bindtextdomain()"
|
||||||
|
endtry
|
||||||
set encoding&
|
set encoding&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -704,6 +704,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 */
|
||||||
|
/**/
|
||||||
|
560,
|
||||||
/**/
|
/**/
|
||||||
559,
|
559,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -598,7 +598,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
|
|||||||
# ifdef bindtextdomain
|
# ifdef bindtextdomain
|
||||||
# undef bindtextdomain
|
# undef bindtextdomain
|
||||||
# endif
|
# endif
|
||||||
# define bindtextdomain(x, y) // empty
|
# define bindtextdomain(x, y) ""
|
||||||
# ifdef bind_textdomain_codeset
|
# ifdef bind_textdomain_codeset
|
||||||
# undef bind_textdomain_codeset
|
# undef bind_textdomain_codeset
|
||||||
# endif
|
# endif
|
||||||
|
Reference in New Issue
Block a user