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>
diff --git a/src/testdir/test_gettext.vim b/src/testdir/test_gettext.vim
index 6a5aafd..a990121 100644
--- a/src/testdir/test_gettext.vim
+++ b/src/testdir/test_gettext.vim
@@ -1,5 +1,7 @@
 source check.vim
 
+CheckFeature gettext
+
 " Test for gettext()
 func Test_gettext()
   call assert_fails('call bindtextdomain("test")', 'E119:')
diff --git a/src/testdir/test_gettext_cp1251.vim b/src/testdir/test_gettext_cp1251.vim
index c91f784..69d2bbf 100644
--- a/src/testdir/test_gettext_cp1251.vim
+++ b/src/testdir/test_gettext_cp1251.vim
@@ -2,22 +2,32 @@
 " This fail on CI MacOS 14 because bindtextdomain() is not available there
 " (missing library?)
 CheckNotMac
+CheckFeature gettext
 
 " Test for gettext()
 func Test_gettext()
   set encoding=cp1251
-  call bindtextdomain("__PACKAGE__", getcwd())
+  call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+
   try
-    language messages ru_RU
-    call assert_equal('ÎØÈÁÊÀ: ', gettext("ERROR: ", "__PACKAGE__"))
-  catch /^Vim\%((\a\+)\)\=:E197:/
-    throw "Skipped: not possible to set locale to ru (missing?)"
-  endtry
-  try
-    language messages en_GB.UTF-8
-    call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
-  catch /^Vim\%((\a\+)\)\=:E197:/
-    throw "Skipped: not possible to set locale to en (missing?)"
+    call assert_true(bindtextdomain("__PACKAGE__", getcwd()))
+
+    try
+      language messages ru_RU
+      call assert_equal('ÎØÈÁÊÀ: ', gettext("ERROR: ", "__PACKAGE__"))
+    catch /^Vim\%((\a\+)\)\=:E197:/
+      throw "Skipped: not possible to set locale to ru (missing?)"
+    endtry
+
+    try
+      language messages en_GB.UTF-8
+      call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+    catch /^Vim\%((\a\+)\)\=:E197:/
+      throw "Skipped: not possible to set locale to en (missing?)"
+    endtry
+
+  catch /^Vim\%((\a\+)\)\=:E342:/
+    throw "Skipped: out of memory executing bindtextdomain()"
   endtry
   set encoding&
 endfunc
diff --git a/src/testdir/test_gettext_utf8.vim b/src/testdir/test_gettext_utf8.vim
index 7862e39..b96f8ea 100644
--- a/src/testdir/test_gettext_utf8.vim
+++ b/src/testdir/test_gettext_utf8.vim
@@ -2,22 +2,32 @@
 " This fail on CI MacOS 14 because bindtextdomain() is not available there
 " (missing library?)
 CheckNotMac
+CheckFeature gettext
 
 " Test for gettext()
 func Test_gettext()
   set encoding=utf-8
-  call bindtextdomain("__PACKAGE__", getcwd())
+  call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+
   try
-    language messages ru_RU
-    call assert_equal('ОШИБКА: ', gettext("ERROR: ", "__PACKAGE__"))
-  catch /^Vim\%((\a\+)\)\=:E197:/
-    throw "Skipped: not possible to set locale to ru (missing?)"
-  endtry
-  try
-    language messages en_GB.UTF-8
-    call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
-  catch /^Vim\%((\a\+)\)\=:E197:/
-    throw "Skipped: not possible to set locale to en (missing?)"
+    call assert_true(bindtextdomain("__PACKAGE__", getcwd()))
+
+    try
+      language messages ru_RU
+      call assert_equal('ОШИБКА: ', gettext("ERROR: ", "__PACKAGE__"))
+    catch /^Vim\%((\a\+)\)\=:E197:/
+      throw "Skipped: not possible to set locale to ru (missing?)"
+    endtry
+
+    try
+      language messages en_GB.UTF-8
+      call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+    catch /^Vim\%((\a\+)\)\=:E197:/
+      throw "Skipped: not possible to set locale to en (missing?)"
+    endtry
+
+  catch /^Vim\%((\a\+)\)\=:E342:/
+    throw "Skipped: out of memory executing bindtextdomain()"
   endtry
   set encoding&
 endfunc