support negative number, so we can set all bits of a debug mask with -1
[libfirm] / ir / debug / debugger.c
index 0bab606..31689e6 100644 (file)
@@ -979,12 +979,19 @@ static unsigned get_token(void) {
 
                do {
                        c = next_char();
-               } while (c == '_' || isalnum(c));
+               } while (isgraph(c));
                unput();
                lexer.len = lexer.curr_pos - lexer.s;
                return tok_identifier;
-       } else if (isdigit(c)) {
+       } else if (isdigit(c) || c == '-') {
                unsigned number = 0;
+               unsigned sign   = 0;
+
+               /* we support negative numbers as well, so one can easily set all bits with -1 */
+               if (c == '-') {
+                       sign = 1;
+                       c    = next_char();
+               }
 
                if (c == '0') {
                        c = next_char();
@@ -1008,11 +1015,11 @@ static unsigned get_token(void) {
                for (;;) {
                        if (! isdigit(c))
                                break;
-                       number = (number << 4) | (c - '0');
+                       number = number * 10 + (c - '0');
                        c = next_char();
                }
                unput();
-               lexer.number = number;
+               lexer.number = sign ? 0 - number : number;
                return tok_number;
        }
        else if (c == '\0')