Hi Collin,
Collin Funk wrote:
> The first patch is a prerequisite to fixing a GNU coreutils bug. It adds
> a posixtime_z function which operates on a timezone_t instead of the TZ
> environment variable.
Why do you add the timezone_t as first argument?
The common rules / guidelines for argument ordering in C APIs are:
- If there are only input parameters, the arguments are sorted
so that the ones with most variation come first and the ones
which are the same among different invocations come last.
- Input parameters that belong together (semantically) come close
together.
- If there is an output parameter, this argument comes first,
before all input parameters.
By the third of these guidelines, I would define the function as
bool posixtime_z (time_t *p, timezone_t tz, const char *s,
unsigned int syntax_bits);
Note that this is not the same situation as for mktime_z.
mktime_z has a parameter that is input/output, not just output.
But for mktime_z too I would have put the timezone_t argument in
the second place; I don't know why Paul chose to put it first in 2015.
Bruno