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).
https://github.com/vim/vim/pull/21122
(9 files)
—
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.![]()
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.![]()
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.![]()