Re: OUTLAW Function

From: ShadowLord (
Date: 01/03/96

On Wed, 3 Jan 1996, Thomas Pedersen wrote:

> Well if you want "yes" for confirm, it will set flag if you say anything 
> but that according to the above snip of code. 
>       if (strcmp(arg, "yes") || strcmp(arg, "YES")) {  ......

Unfortunately, you're wrong.  Your code will do it unless you put in 
"yes".  Here's how it should look (and why):

/* make sure you use "one_argument(argument, arg)", too */

if (!str_cmp(arg, "yes")) {
  /* then the code */

As for why?  strcmp (and the case insensitive version that is in utils.c) 
return 0 when the strings are an exact match.  If it returns below zero 
then arg < "yes", if it returns above zero, then arg > "yes".  Therefore, 
if you use:

if (str_cmp(arg, "yes")) {
  /* code */

The code within the if statement will always be executed _UNLESS_ arg == 
"yes".  It'd be much easier if you could handle strings like you can in 
most BASIC-like languages with the various C extensions to them, but you 
cannot in C (although I've heard you can with classes in C++, personally, 
I wouldn't know for sure since I've not taken the time to actually learn 
C++'s various oddities and new features).

Just an important little tip and a sidebar...

Good luck,
   Daniel Koepke <>

ps., I posted this to the list so newbies wouldn't be confused by the 
mis-information, sorry if almost everyone and their mother's knew this, 
but not everyone knows (which is obviously true, since Thomas [the person 
who made] the incorrect statement didn't know, apparently).  I am not 
trying to flame Thomas.

This archive was generated by hypermail 2b30 : 12/07/00 PST