mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-29 07:44:48 -05:00

Up-to-date trunk clang has introduced a built-in operator called _Countof, which is like the 'lenof' macro in this code (returns the number of elements in a statically-declared array object) but with the safety advantage that it provokes a compile error if you accidentally use it on a pointer. In this commit I add a cmake-time check for it, and conditional on that, switch over the definition of lenof. This should add a safety check for accidental uses of lenof(pointer). When I tested it with new clang, this whole code base compiled cleanly with the new setting, so there aren't currently any such accidents. clang cites C2y as the source for _Countof: WG14 document N3369 initially proposed it under a different name, and then there was a big internet survey about naming (in which of course I voted for lenof!), and document N3469 summarises the results, which show that the name _Countof and/or countof won. Links: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3369.pdf https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm My reading of N3469 seems to say that there will _either_ be _Countof by itself, _or_ lowercase 'countof' as a new keyword, but they don't say which. They say they _don't_ intend to do the same equivocation we had with _Complex and _Bool, where you have a _Countof keyword and an optional header file defining a lowercase non-underscore macro wrapping it. But there hasn't been a new whole draft published since N3469 yet, so I don't know what will end up in it when there is. However, as of now, _Countof exists in at least one compiler, and that seems like enough reason to implement it here. If it becomes 'countof' in the real standard, then we can always change over later. (And in that case it would probably make sense to rename the macro throughout the code base to align with what will become the new standard usage.)
PuTTY source code README ======================== This is the README for the source code of PuTTY, a free Windows and Unix Telnet and SSH client. PuTTY is built using CMake <https://cmake.org/>. To compile in the simplest way (on any of Linux, Windows or Mac), the general method is to run these commands in the source directory: cmake . cmake --build . These commands will expect to find a usable compile toolchain on your path. So if you're building on Windows with MSVC, you'll need to make sure that the MSVC compiler (cl.exe) is on your path, by running one of the 'vcvars32.bat' setup scripts provided with the tools. Then the cmake commands above should work. To install in the simplest way on Linux or Mac: cmake --build . --target install On Unix, pterm would like to be setuid or setgid, as appropriate, to permit it to write records of user logins to /var/run/utmp and /var/log/wtmp. (Of course it will not use this privilege for anything else, and in particular it will drop all privileges before starting up complex subsystems like GTK.) The cmake install step doesn't attempt to add these privileges, so if you want user login recording to work, you should manually ch{own,grp} and chmod the pterm binary yourself after installation. If you don't do this, pterm will still work, but not update the user login databases. Documentation (in various formats including Windows Help and Unix `man' pages) is built from the Halibut (`.but') files in the `doc' subdirectory. If you aren't using one of our source snapshots, you'll need to do this yourself. Halibut can be found at <https://www.chiark.greenend.org.uk/~sgtatham/halibut/>. The PuTTY home web site is https://www.chiark.greenend.org.uk/~sgtatham/putty/ If you want to send bug reports or feature requests, please read the Feedback section of the web site before doing so. Sending one-line reports saying `it doesn't work' will waste your time as much as ours. See the file LICENCE for the licence conditions.
Description
Languages
C
89.7%
Python
8%
Perl
0.9%
CMake
0.8%
Shell
0.4%
Other
0.1%