svn commit: r328486 - head/usr.bin/fortune/fortune

Bruce Evans brde at optusnet.com.au
Sun Jan 28 00:08:33 UTC 2018


On Sat, 27 Jan 2018, Ian Lepore wrote:

> On Sat, 2018-01-27 at 22:56 +0000, Conrad Meyer wrote:
>> I donÿt think dragonfly has anything to do with this?  If youÿre
>> converting
>> bool increments to setting true values in FreeBSD, use
>> ´true.¡  Thatÿs all
>> there is to it.
>
> style(9) emphasizes internal consistancy in several places.  The
> uppercase TRUE/FALSE is currently the style within that code, so it
> makes sense to stick with it.  If a (somewhat gratuitous) conversion to
> the new style is made, it should be a separate commit just for that,
> emphasizing that it changes just style and not functionality.

fortune.c has already been churned and broken by gratuitous conversion to
use bool.

It used to use "#define bool short".  It also defined its own TRUE and FALSE
as 1 and 0.  This was almost correct.  The bools were sometimes set bogusly
to TRUE using the PDP-11 micro-optimization of incrementing them (this can
overflow in theory, but in practice it is hard to have enough command line
args to overflow even short variables by incrementing them by 1 per arg).
The `Debug' variable was tri-state, but its type was misspelled bool and
it was bogusly initialized to FALSE.

This was changed in r242576 by including <stdbool.h>, removing the private
definition of bool, and changing the definitions of TRUE and FALSE to true
and false.  This did no good, but exposed the brokenness of 'Debug' and
created mounds of style bugs (spelling true and false as TRUE and FALSE,
and requiring more magic for the PDP-11ism's to work).

r242577 increased the style bugs by using true and false directly in new
code.

'Debug' was fixed in r243036.

This commit is to remove the PDP11-isms.  Although they work even
better with real bools than with shorts (incrementing a bool clamps
it to 1, but incrementing a short always increments it unless it
overflows), they are larger obfuscations with bools than with shorts
and some compilers apparently warn about them.  This commit preserves
the old style of using TRUE and FALSE instead of true and false.

style(9) only mildly discourages converting old code to use bool ("may
be converted if it is reasonable to").  It says that the spellings
true and false are preferred, but should only say that the are preferred
in code that uses bool.

Bruce


More information about the svn-src-all mailing list