Author Topic: A bug about switch/case in FluffOS 2.20  (Read 2242 times)

Offline reallove

  • Acquaintance
  • *
  • Posts: 8
    • View Profile
A bug about switch/case in FluffOS 2.20
« on: August 09, 2010, 03:56:33 AM »
Sometimes , the switch/case is not work.

Test code:
Code: [Select]
switch(subclass) {
                        case "channel":
                                log_file("output_debug", sprintf("subclass:%s, msgclass:%s\n", subclass, msgclass));
                                if( !pointerp(ch = query("channels")) || member_array(msgclass, ch)==-1 )
                                        return;
                                break;
                        case "outdoor":
                                log_file("output_debug", sprintf("subclass:%s, msgclass:%s\n", subclass, msgclass));
                                if( !environment() || !environment()->query("outdoors") )
                                        return;
                                break;
                        case "weather":
                                log_file("output_debug", sprintf("subclass:%s, msgclass:%s\n", subclass, msgclass));
                                if( !environment() || !environment()->query("weather") )
                                        return;
                                break;
                      // added by Zen.
            case "wizard":
                    log_file("output_debug", sprintf("subclass:%s, msgclass:%s\n", subclass, msgclass));
                if( msgclass != ob->query("id") && msgclass != wizhood(ob) )
                    return;
                break;
                        default:
                                log_file("output_debug", sprintf("Invalid subclass:%s, msgclass:%s\n", subclass, msgclass));
                                return;
                }

and I input some word to test, then more output_debug.log


Invalid subclass:channel, msgclass:debug
Invalid subclass:channel, msgclass:notice
Invalid subclass:channel, msgclass:notice
Invalid subclass:channel, msgclass:debug
Invalid subclass:channel, msgclass:notice
Invalid subclass:channel, msgclass:debug
Invalid subclass:channel, msgclass:chat
Invalid subclass:channel, msgclass:chat
Invalid subclass:channel, msgclass:chat
Invalid subclass:channel, msgclass:xkx
subclass:weather, msgclass:Ss
Invalid subclass:wizard, msgclass:reallove
Invalid subclass:outdoor, msgclass:ss

Only the case "weather" can be recognized.

It seems to be a bug.  any suggestions?

Offline wodan

  • BFF
  • ***
  • Posts: 434
  • Drink and code, you know you want to!
    • View Profile
Re: A bug about switch/case in FluffOS 2.20
« Reply #1 on: August 09, 2010, 04:02:37 AM »
Add the missing code for a complete test case, this has been reported on discworld a few times, but it always included too much code to even start looking for the cause, this looks potentially small enough to investigate. If you can cut it down to the minimal failing case that would be great!

Offline reallove

  • Acquaintance
  • *
  • Posts: 8
    • View Profile
Re: A bug about switch/case in FluffOS 2.20
« Reply #2 on: August 10, 2010, 02:57:36 AM »
In function f_switch()

there is two variable:

POINTER_INT s;
POINTER_INT r;

the type is POINTER_INT

then I found that POINTER_INT is signed.

when I run my code, it get a negative number.  I think it's the cause.

please check it.

maybe we should #define POINTER_INT unsigned ??