From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Neil Conway <neilc(at)samurai(dot)com>, pgsql-committers(at)postgresql(dot)org |
Subject: | Re: pgsql: Clarify coding of .exe patch |
Date: | 2004-11-01 05:06:57 |
Message-ID: | 200411010506.iA156vv16695@candle.pha.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > ! if (strlen(nodir_name) > sizeof(EXE) - 1 &&
> > ! pg_strcasecmp(nodir_name + strlen(nodir_name)-sizeof(EXE)-1, EXE) == 0)
>
> This is clearer than "4"?
>
> If there were any remote chance that Microsoft would invent some new,
> different-length spelling of the ".exe" suffix in the foreseeable
> future, I might agree that this was good code. As is, it looks like
> unhelpful obscurantism, because it requires a very close reading of the
> details of the C spec to confirm that it is correct and not wrong.
>
> Code that looks wrong on its face is not an improvement over code that
> is readable but doesn't cover changes that won't ever happen.
The '4' to me just looks too arbitrary --- the EXE reference makes it
clear to me what it. I don't like arbitrary constants in the code and
especially not repeated several places.
As I just posted I would like us to create a global define that is
sizeof()-1 so it would be clear, perhaps CC_STRLEN() as a define name.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2004-11-01 05:26:33 | Re: pgsql: Clarify coding of .exe patch |
Previous Message | Bruce Momjian | 2004-11-01 05:04:13 | Re: pgsql: Clarify coding of .exe patch |