[vim/vim] Reject non-string-literal arguments to STRLEN_LITERAL (PR #21122)

6 views
Skip to first unread message

Shane Harper

unread,
Aug 22, 2026, 8:04:58 AM (11 days ago) Aug 22
to vim/vim, Subscribed

Problem: STRLEN_LITERAL silently expands to an expression that doesn't
determine a string's length if it's given a non-string-literal
token.
Solution: Modify STRLEN_LITERAL so that a non-string-literal argument
produces a compile error.

Regarding character arrays:

A compilation error will now be generated for the following:
char s[64] = "12345";
int l = STRLEN_LITERAL(s); // previously l was assigned 63 (not 5).
Had s been defined as:
char s[] = "12345";
the original definition of STRLEN_LITERAL would have correctly
determined the string length to be 5; however, the macro cannot
distinguish a padded array like the first from an exactly-sized one like
the second, so both are rejected.

Regarding PATHSEPSTR:

On MS-Windows, PATHSEPSTR does not expand to a string-literal token, so
STRLEN_LITERAL(PATHSEPSTR) fails to compile. Each
STRLEN_LITERAL(PATHSEPSTR) is replaced with sizeof(PATHSEP).
sizeof(PATHSEP) is now always 1; previously it was 1 (sizeof(char_u)) on
MS-Windows but sizeof(int) elsewhere. (PATHSEP is a single character;
PATHSEPSTR is a null-terminated string with a single content byte
followed by NUL.)

Supported by AI (Claude Sonnet 5).


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

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

Commit Summary

  • cb9d39e Reject non-string-literal arguments to STRLEN_LITERAL
  • acb1fda Fix MS-Windows build

File Changes

(9 files)

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/21122@github.com>

Christian Brabandt

unread,
Aug 23, 2026, 3:01:51 PM (10 days ago) Aug 23
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21122)

thanks


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/21122/c5387895356@github.com>

h_east

unread,
Aug 23, 2026, 3:48:33 PM (10 days ago) Aug 23
to vim/vim, Subscribed
h-east left a comment (vim/vim#21122)

related: #19725


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/21122/c5388107464@github.com>

Reply all
Reply to author
Forward
0 new messages