From rlpowell@digitalkingdom.org Thu Jan 23 09:41:46 2003 Received: with ECARTIS (v1.0.0; list lojban-list); Thu, 23 Jan 2003 09:41:47 -0800 (PST) Received: from rlpowell by digitalkingdom.org with local (Exim 4.05) id 18blME-0000S8-00 for lojban-list@lojban.org; Thu, 23 Jan 2003 09:41:42 -0800 Date: Thu, 23 Jan 2003 09:41:42 -0800 To: lojban-list@lojban.org Subject: [lojban] Re: C question: How to or strings and get a string? Message-ID: <20030123174142.GJ12363@digitalkingdom.org> Mail-Followup-To: lojban-list@lojban.org References: <200301222226.16684.phma@webjockey.net> <20030123173921.GI12363@digitalkingdom.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030123173921.GI12363@digitalkingdom.org> User-Agent: Mutt/1.5.3i From: Robin Lee Powell X-archive-position: 3865 X-ecartis-version: Ecartis v1.0.0 Sender: lojban-list-bounce@lojban.org Errors-to: lojban-list-bounce@lojban.org X-original-sender: rlpowell@digitalkingdom.org Precedence: bulk Reply-to: lojban-list@lojban.org X-list: lojban-list On Thu, Jan 23, 2003 at 09:39:21AM -0800, Robin Lee Powell wrote: > On Wed, Jan 22, 2003 at 10:26:16PM -0500, Pierre Abbat wrote: > > I am very close to having a tolpo'u a'o ke valfendi mutmi'i. There are > > a few lines in the program that I'm not sure how to fix: > > > > #define is3rafsi(str) (monmapti("ICV",str) || monmapti("CVC",str) || monmapti("CUV",str)) > > #define is4rafsi(str) (monmapti("CVCC",str) || monmapti("ICVC",str)) > > #define isgismu(str) (monmapti("CVCCV",str) || monmapti("ICVCV",str)) > > > > monmapti returns NULL if it didn't match or a pointer to the first > > character after the matching string if it does. is3rafsi is supposed > > to do the same, but instead it returns 1, > > Of course it does. You're asking for a boolean OR. Any non-zero in C > is boolean TRUE. A boolean operator that returns true returns 1, IIRC. > > I'm not sure what the problem is. > > If you want to return one or the other of a couple of options depending > on whether the first is true, you want: > > #define is4rafsi(str) (monmapti("CVCC",str) ? monmapti("CVCC",str): monmapti("ICVC",str)) > > IIRC. For reference: http://www.eskimo.com/~scs/C-faq/q9.2.html -Robin -- http://www.digitalkingdom.org/~rlpowell/ *** I'm a *male* Robin. .i le pamoi velru'e zo'u crepu le plibu taxfu .i le remoi velru'e zo'u mo .i le cimoi velru'e zo'u ba'e prali .uisai http://www.lojban.org/ *** to sa'a cu'u lei pibyta'u cridrnoma toi