Re: Memo on coding practices: strcmp() does not yield bool

From: JanWieck(at)t-online(dot)de (Jan Wieck)
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Memo on coding practices: strcmp() does not yield bool
Date: 2000-07-07 00:43:27
Message-ID: 200007070043.CAA20793@hot.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> I've occasionally griped that I do not like the coding practice of
> writing
> if (strcmp(foo, bar))
> to mean
> if (strcmp(foo, bar) != 0)
>
> [...]
>
> Up till just now, ruleutils.c contained code like this:
>
> bool tell_as = FALSE;
>
> /* Check if we must say AS ... */
> if (!IsA(tle->expr, Var))
> tell_as = strcmp(tle->resdom->resname, "?column?");
>
> [...]

Yeah, blame me for that one.

Oh boy. Originally I wrote ruleutils.c as a proof that
rewrite rules "can" tell what the original rule (or view)
looked like. Someone called it a "magic piece of software"
and we adopted it as a useful thing to dump views and rules
(what we wheren't able before). Now you blame me for it's
uglyness.

Well done! I was so proude beeing able to show how much I
knew about rewrite rules by coding a reverse interpreter for
them. Just that I was too lazy to code it in a good style.

Remind me on it if I ever ask "what should I do next".

:-)

Jan

PS: I'm sure Tom can read between the lines what I really wanted
to say. For anyone else: The functionality of ruleutils.c is
checked in the regression suite. None of the ports reported
problems so far, so the requested style fixes are more or
less of cosmetic nature by now. I'm more than busy doing
other things actually. If someone else want's to learn
abount the internals of rules, touch it and become
responsible for it.

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Bitmead 2000-07-07 00:46:35 Re: heap_create with OID?
Previous Message Richard Sand 2000-07-07 00:15:48 Re: Lessons learned on how to build 7.0.2 on AIX 4.x