[vim/vim] (Try to) gracefully handle out-of-memory in bindtextdomain(). (PR #15116)

31 views
Skip to first unread message

cvwillegen

unread,
Jun 27, 2024, 11:37:35 AM6/27/24
to vim/vim, Subscribed

The error return value of bindtextdomain() was not propagated to the original calling script. This implements returning FALSE when the call fails, and TRUE when it succeeds.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/15116

Commit Summary

  • 045c4cf (Try to) gracefully handle out-of-memory in bindtextdomain().

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15116@github.com>

zeertzjq

unread,
Jul 3, 2024, 7:06:07 AM7/3/24
to vim/vim, Subscribed

Build failure on macos-14


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15116/c2205813761@github.com>

Christ van Willegen

unread,
Jul 3, 2024, 7:43:16 AM7/3/24
to vim...@googlegroups.com, reply+ACY5DGDZB4ITTRLZAA...@reply.github.com, vim/vim, Subscribed


Op wo 3 jul. 2024 13:06 schreef zeertzjq <vim-dev...@256bit.org>:

Build failure on macos-14


Is the return type on OS-14 different? It gives me a ... weird error. Expression expected??

The other uses of the function don't check the return value, so I can't see how it "should" be done.

I propose we don't check the return value. Getting an out of memory error here looks very unlikely...

Christ van Willegen

vim-dev ML

unread,
Jul 3, 2024, 7:43:55 AM7/3/24
to vim/vim, vim-dev ML, Your activity

Op wo 3 jul. 2024 13:06 schreef zeertzjq ***@***.***>:


> Build failure on macos-14
>

Is the return type on OS-14 different? It gives me a ... weird error.
Expression expected??

The other uses of the function don't check the return value, so I can't see
how it "should" be done.

I propose we don't check the return value. Getting an out of memory error
here looks very unlikely...

Christ van Willegen

>


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15116/c2205881591@github.com>

Christian Brabandt

unread,
Jul 4, 2024, 7:18:40 AM7/4/24
to vim/vim, vim-dev ML, Comment

Hm, not sure what is wrong on MacOS. Perhaps change this:

if (bindtextdomain((const char *)argvars[0].vval.v_string, (const char *)argvars[1].vval.v_string) == NULL)

to

if (!bindtextdomain((const char *)argvars[0].vval.v_string, (const char *)argvars[1].vval.v_string))


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15116/c2208722060@github.com>

LemonBoy

unread,
Jul 4, 2024, 7:23:44 AM7/4/24
to vim/vim, vim-dev ML, Comment

In this case the check expands to ( == NULL), that's a problem. The macros should expand to some non-null value.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15116/c2208729773@github.com>

cvwillegen

unread,
Jul 11, 2024, 6:23:35 AM7/11/24
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.

  • 472540b Make bindtextdomain() return 'something'.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15116/before/045c4cfc2a47777566a3707a7594e4c53239badc/after/472540b1310709176b1398420c3ac639e26c3723@github.com>

K.Takata

unread,
Jul 11, 2024, 6:28:25 AM7/11/24
to vim/vim, vim-dev ML, Comment

@k-takata commented on this pull request.


In src/testdir/test_gettext.vim:

> @@ -2,15 +2,17 @@ source check.vim
 
 " Test for gettext()
 func Test_gettext()
-  call assert_fails('call bindtextdomain("test")', 'E119:')
-  call assert_fails('call bindtextdomain("vim", "test")', 'E475:')
+  if has("gettext")

CheckFeature gettext might be better?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15116/review/2171520616@github.com>

LemonBoy

unread,
Jul 11, 2024, 7:17:52 AM7/11/24
to vim/vim, vim-dev ML, Comment

@LemonBoy commented on this pull request.


In src/vim.h:

> @@ -598,7 +598,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
 # ifdef bindtextdomain
 #  undef bindtextdomain
 # endif
-# define bindtextdomain(x, y) // empty
+# define bindtextdomain(x, y) (y)
⬇️ Suggested change
-# define bindtextdomain(x, y) (y)
+# define bindtextdomain(x, y) ""

This is better as bindtextdomain(<whatever>, NULL) does not return NULL (unless there's something wrong).


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: <vim/vim/pull/15116/review/2171611623@github.com>

cvwillegen

unread,
Jul 11, 2024, 12:42:40 PM7/11/24
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.

  • 5da022a Apply feedback from code review.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15116/before/472540b1310709176b1398420c3ac639e26c3723/after/5da022a1b3e811723511431898249d34480aeefa@github.com>

Christian Brabandt

unread,
Jul 11, 2024, 3:39:06 PM7/11/24
to vim/vim, vim-dev ML, Comment

thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15116/c2223735816@github.com>

Christian Brabandt

unread,
Jul 11, 2024, 3:39:21 PM7/11/24
to vim/vim, vim-dev ML, Comment

Closed #15116 via 8252ef1.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15116/issue_event/13476635027@github.com>

Reply all
Reply to author
Forward
0 new messages