[DGD] break bug?

Noah Gibbs noah_gibbs at yahoo.com
Tue Oct 30 16:42:28 CET 2007


  It looks a lot like your STATE_NORMAL case code in the switch() statement
drops straight down through into your STATE_INPUT_TO case.  Is that
intentional?  I think you need a 'break' there if you don't want that to
happen.

  You have one break, but I'd expect it to break out of the for(), but not the
switch().

--- "chris ." <psych_mayo at hotmail.com> wrote:

> 
> I am probably not using break right, but i do not see how, so here is the
> relevant code 
> from my gpl lib, Windfall.
> I took out comments originally in place and commented where i think my
> problems are.
> 
> <omitted>
> 
> # define STATE_NORMAL        0
> # define STATE_INPUT_TO     1
> # define STATE_EDITOR        2
> 
> <omitted> 
> 
> int receive_message(string str) {
>   if(previous_program() == LIB_CONN) {
>     string cmd, arg; 
>     object user, *users;
>     int i, ii;
> 
> <omitted>
> 
> case STATE_NORMAL:
>         if(sscanf(str,"%s %s",cmd,arg) != 2)
>                 cmd = str;
>             for(i=0;i < sizeof(cmd_dirs);i++) {
>                 if(read_file(COMMANDS+cmd_dirs[i]+"/"+cmd+".c") ) {
>             i = call_other( (COMMANDS+cmd_dirs[i]+"/"+cmd), "main", arg); 
> /*sets i to 0, STATE_NORMAL, in my test condition*/ 
>               if(i >= 0) {
>                   previous_object()->message((string)i+"\n"); /*is 0 when
> testing*/
>                 state[previous_object()] = i;
>                    
> previous_object()->message((string)state[previous_object()]); 
> /*copy of i is still 0*/
>                     }
>               else { 
>                 return MODE_DISCONNECT;
>                 }
>                 break; 
> /*breaking out of the for loop?*/
>             }
>           }
>       case STATE_INPUT_TO:
>           previous_object()->message((string)i);
> /*still 0?..whats up?*/
> 
> Thanks for help as always.
> 
> 
> _________________________________________________________________
> Windows Live Hotmail and Microsoft Office Outlook � together at last.
�Get it
> now.
>
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033___________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd
> 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the DGD mailing list