Re: [CODE] An online MOTD and IMOTD editor

From: Mark Dickey (mark@BESTWEB.NET)
Date: 12/15/97


I would think that it is obvious that it is going into an infinite loop in
the code.  Since the only two places where ti could do that is the two
whiles, lets look at them.



On Mon, 15 Dec 1997, Chuck Reed wrote:

> Hello.  I have been working on an on-line imotd/motd editor and thought
> I was done when I ran into a problem I can't figure out.  The problem is
> that, when I enter the command (motd_edit), it simply freezes the game.

> ACMD(do_edit_motd)
> {
>   #define MOTD "text/motd"
>   int i = TRUE;
>   FILE *f;
>   char buf2[100];
>
>   f = fopen(MOTD,"w");
>   send_to_char("Enter a new MOTD below:\r\n", ch);
>     while(i != FALSE) {

This one looks fine, i will == FALSE once buf2 is == "\s".  and buf2 is
taken each round.

>        send_to_char("] ", ch);
>        scanf("%s", buf2);
>          while(buf2 != "/s")

Now, this one doesn't look so great, it will keep dprintfing until buf2 !=
"\s"  BUT!  If it can get into the while statement, it cannot ever get
out, and if it gets out, buf2 cannot ever equal "\s" and manage to get out
of the code.

>             fprintf(f, "%s\r\n", buf2);
>    if(buf2 == "/s")
>    i = FALSE;
>   }
>  fclose(f);
> }

Now, to fix this, I would just delete that second while.  I don't see a
purpose for it being in there, and it is causing the problem.

I hope this gets it working.

Mark Dickey
Cyon


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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