FW: changes to zdump.c and zic.c invocations of is.* macros

Robert Elz kre at munnari.OZ.AU
Fri Dec 9 12:29:15 UTC 2005

    Date:        Thu, 08 Dec 2005 13:23:21 -0800
    From:        Paul Eggert <eggert at CS.UCLA.EDU>
    Message-ID:  <873bl39tbq.fsf at penguin.cs.ucla.edu>

  | But the zic stuff attempts to be portable to C89 (as
  | well as earlier) compilers.

OK, though I can't imagine a C implementation where it wouldn't work
(whatever C89 might technically allow...)

  | Alas, that's not true in practice.  isdigit is typically slower, and
  | it can be quite a bit slower.

For zic/zdump I don't care which is faster or slower (it might
be different if this code were in localtime or similar).   What
I said was "better" not "faster".

  | > Paul's version may be textually shorter, but with that cp++ side effect
  | > buried in the middle of the && sequence, it is not nearly as easy to
  | > read.
  | True, but in my defense that buried cp++ was in the original code.

It isn't the side effect itself I minded, but the buried side
effect in the middle of a long expression.  I have no problem with
	if (*cp++ == 0)
(or similar) types of expressions, that's ancient C idiom that anyone can
(should be able to) comprehend easily.   But when you have to look hard to
figure out under what circumstances the "++" actually gets executed, then
I start to look for a better way to write the code.

  | How about this instead?  It might be a bit clearer.

Aside from the switch away from using isdigit() that's pretty much what was
there already, isn't it?  (OK, it moves out the ++ from the if, but there
was no real need to do that in the original).

Incidentally, if you wanted to not use isdigit(), rather than writing out
the expression longhand, I'd just define a new macro that does the test.
That way, it is trivial to switch between using isdigit() or using the
specific tests against '0' and '9' just by altering the new macro definition.


More information about the tz mailing list