proposed changes to eliminate P macro

Robert Elz kre at munnari.OZ.AU
Thu Nov 15 08:47:27 UTC 2007

    Date:        Tue, 13 Nov 2007 16:36:34 -0800
    From:        Ken Pizzini <tz_ at>
    Message-ID:  <20071114003634.GA26243 at>

  |   * use angle brackets <> instead of double-quotes for system #include-s,
  |     for the benefit of any compiler that handles those more efficiently
  |     (e.g., support of pre-compiled system headers)

The change you're doing there should be OK, but the rationale you give
makes no sense to me ... all <> ever did in C was to skip the default
search of the current directory for the file to include - but if -I.
is given, that comes back again - there's no real distinction (in the
syntax of the #include) between "system" and other include files.
If the compiler wants to support pre-"compiled" include files, it needs
some other mechanism to recognise them than the <> vs "" in the .c file.

  |   * removes some conditionals that were only needed to support pre-C89
  |     compilers (like "cc" on SunOS 4.x and older); this includes:

I'm not sure I'd be doing all of those - sure, in most cases they simplify
things a little, but (perhaps aside from the isascii() changes) they're
not really altering anything that matters.   That is, the P() stuff,
(and isascii()) are littered everywhere, getting rid of that old cruft
makes the code easier to read.   On the other hand, having a local
strerror() defined in case the system is missing one (as remote a chance
as that possibility is) really harms nothing - that declaration is
trivially ignored, and affects reading/understanding (and compiling/using)
the code in no way at all.

That is, don't make changes just for the sake of changing things, even if
it is strictly OK to do that, and even if you wouldn't bother to do it the
old way if you were writing the code today - there needs to be some positive
benefit to the change to justify all the work everyone else is going to need
to do looking over the diffs from the last version before integrating the
updated code into the many distributions that use it.

What I might change however is to make some of the casts a little
safer (perhaps only for defective compilers, but still...)

Eg: if we have char *cp; and want to use an unsigned char (particularly
for args to the isalpha() etc macros), I'd feel safer writing

	*(unsigned char *)cp
rather than the
	(unsigned char) *cp
that now exists.   I just don't trust compilers to always evaluate the
latter correctly.

Or even better, where essentially all uses of *cp in a function want an
unsigned char (or would work with unsigned char - and as "char" might
be unsigned anyway, that should be just about all of them) I'd just
declare it as "unsigned char *cp" and then remove all of the casts on
the uses of *cp (instead perhaps adding a cast where cp is initialised,
from, and perhaps compared with, a char * pointer that can't as easily
be changed.

But even that I'd be hesitant about changing, just for the sake of it,
if what's there now causes problems for no-one, then leave it alone.


More information about the tz mailing list