-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[RFC] vim-patch:7.4.490 #1729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] vim-patch:7.4.490 #1729
Conversation
@@ -2017,17 +2017,24 @@ int diff_infold(win_T *wp, linenr_T lnum) | |||
} | |||
|
|||
/// "dp" and "do" commands. | |||
/// | |||
/// @param put |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no @param
at all, we get a Doxygen warning that docu is missing for this parameter, which is IMO more useful than an empty parameter description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Empty param descriptions, or descriptions that meaninglessly restate the parameter name (e.g. @param put The thing to put
) are useless noise and should be avoided.
if (count == 0) { | ||
ea.arg = (char_u *)""; | ||
} else { | ||
vim_snprintf(buf, 30, "%ld", count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be %zd
(http://stackoverflow.com/questions/2524611/how-to-print-size-t-variable-portably)?
man 3 printf
:
z A following integer conversion corresponds to a size_t or ssize_t argument, or a following n conversion corresponds to a pointer to a size_t
argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoping MSVC has added that since 2010. @jasonwilliams200OK @aktau @equalsraf Any idea about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that link.
This link claims %z
is C99. Since size_t is unsigned perhaps we should use %zu
.
This MSDN page says (click "expand all" and search for C99):
The printf and scanf families of functions now support the new C99 format string improvements.
Perhaps someone with VS 2015 CTP can check the inttypes.h (or equivalent) header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link claims %z is C99. Since size_t is unsigned perhaps we should use %zu.
I always use %zu
for size_t
, fwiw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted inttypes.h from VS2015 latest preview and here it is: https://gist.github.com/jasonwilliams200OK/45d0b5f4fd2b087e0b3a
And here is the one that shipped with VS2013 Update 4: https://gist.github.com/jasonwilliams200OK/2a0ce733923fbcf86c64 (don't know why they say complex.h in comment in 2013 version?)
Besides the following, all C99 and C11 standard headers are included in CRT (VS2015):
C11 - <stdalign.h>
C11 - <stdatomic.h>
C11 - <stdnoreturn.h>
C99 - <tgmath.h>
C11 - <threads.h>
The only C11 header that is included is <uchar.h>
, which means STL (person) was not kidding in this blog's comment:
My coworker Pat Brenner is actually adding <uchar.h> to the CRT right now, and I've given him to add to the STL. Unless a meteor strikes, this will get into VS14 RTM.
(it was later, they changed the name to VS2015 ... and yes meteor did not strike!)
So now we even know what date uchar.h got included in their CRT! :)
BTW, that list in blog I linked above is now superseded by this one.
PS Matter of time before we would be @
'ing VC guys directly on GH..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer your earlier question @justinmk, I tested with this code (taken from SO link by @fwalch):
// test.c
#include <stdio.h>
#include <BaseTsd.h>
int main()
{
size_t x = 1;
SSIZE_T y = 2;
printf("%zu\n", x); // prints as unsigned decimal
printf("%zx\n", x); // prints as hex
printf("%zd\n", y); // prints as signed decimal
return 0;
}
on both VS2013 and VS2015.
VS2015 generated binary outputs:
1
1
2
while the one generated by VS2013 says:
zu
zx
zd
Note: ssize_t
is a POSIX extension and SSIZE_T
is similar thing in Windows Data Types, hence I added <BaseTsd.h>
reference
Let me know if there is anything else you want me to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasonwilliams200OK that is good news, thanks for the followup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to %zu
, thanks @jasonwilliams200OK!
Problem: Cannot specify the buffer to use for "do" and "dp", making them useless for three-way diff. Solution: Use the count as the buffer number. (James McCoy) https://code.google.com/p/vim/source/detail?r=v7-4-490
Original patch (proto, version.c changes removed for brevity):