Re: [PATCH v4] gc: call "prune --expire 2.weeks.ago" by default
- From
Wincent Colaiuta <win@wincent.com>
- Date
- Mar 13, 2008, 09:48 UTC
- Message-ID
- <7FB80115-C1E4-4F83-9374-41AB1BDA0579@wincent.com>
- In-Reply-To
- <7vod9j342h.fsf@gitster.siamese.dyndns.org>
El 13/3/2008, a las 0:39, Junio C Hamano escribió:
Show 15 quoted lines
> Ah,...
>
> But C language rules haven't changed in such a way that it
> guarantees B to
> be evaluated before A when you write "A >= B", have it?
>
> So at least I think you would need something like this if you go that
> route:
>
> if (strcmp(value, "now")) {
> unsigned long now = approxidate("now");
> if (approxidate(value) >= now)
> return error("Invalid %s: '%s'", var, value);
> ...
> }Are you sure that that alternative provides any guarantees about evaluation order either? (I'm not a compiler expert, nor am I consulting a copy of the standard; but I don't think it does.)
In order to enforce evaluation in the required order I think it might have to be something like this:
if (strcmp(value, "now")) {
unsigned long now;
if ((now = approxidate("now")) &&
approxidate(value) >= now)
return error("Invalid %s: '%s'", var, value);
...
}ie. the && operator guarantees left to right evaluation order, and since approxidate always returns a non-zero ulong the second expression (after the &&) will always be evaluated.
Cheers, Wincent