[vim/vim] use strtol for getdigits on Solaris (PR #20602)

2 views
Skip to first unread message

Vladimír Marek

unread,
Jun 22, 2026, 5:41:32 AM (yesterday) Jun 22
to vim/vim, Subscribed

getdigits() uses atol(), whose overflow behavior is not portable. On Solaris, overflowing atol() can return a wrapped positive value without ERANGE, so Ex address parsing (like :999999999999999999999print) misses the intended out-of-range condition. Use strtol() on Solaris and clamp overflow to the same sentinel values expected by callers. This fixes the Test_address_line_overflow() failure in test_excmd.vim.


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

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

Commit Summary

  • 42a83a5 use strtol for getdigits on Solaris

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20602@github.com>

Christian Brabandt

unread,
Jun 22, 2026, 2:50:10 PM (yesterday) Jun 22
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20602)

I don't really like having system specific ifdefs here. Can't we use something like the following instead:

diff --git a/src/charset.c b/src/charset.c
index bf7c59620..ab860a099 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -2227,15 +2227,18 @@ skiptowhite_esc(char_u *p)
 getdigits(char_u **pp)
 {
     char_u     *p;
-    long       retval;
+    varnumber_T        number;
+    int                len;

     p = *pp;
-    retval = atol((char *)p);
-    if (*p == '-')             // skip negative sign
-       ++p;
-    p = skipdigits(p);         // skip to next non-digit
-    *pp = p;
-    return retval;
+
+    vim_str2nr(p, NULL, &len, 0, &number, NULL, 0, FALSE, NULL);
+    if (number > LONG_MAX)
+       number = LONG_MAX;
+    else if (number < LONG_MIN)
+       number = LONG_MIN;
+    *pp = p + len;
+    return (long)number;
 }

 /*


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

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

Vladimír Marek

unread,
1:25 AM (23 hours ago) 1:25 AM
to vim/vim, Subscribed
vlmarek left a comment (vim/vim#20602)

I can confirm, the suggested diff makes the test(s) pass on solaris on both architectures.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

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

Reply all
Reply to author
Forward
0 new messages