]> git.corax.cc Git - ccc/commitdiff
tokenize: Fix mistaken use of putchar() where putnext() should have been
authorMatthias Kruk <m@m10k.eu>
Sat, 30 May 2020 14:28:27 +0000 (23:28 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 30 May 2020 14:28:27 +0000 (23:28 +0900)
src/tokenize.c

index dcfcfe6042d042ca3a3aa9b40b9f613e18a69ac5..a7adf39d4825a8fbc1674821c21e2c483da14a1a 100644 (file)
@@ -457,7 +457,7 @@ struct token *nexttoken(void)
                                return(token_new2(_line, _col, "-="));
 
                        default:
-                               putchar(c);
+                               putnext(c);
                                return(token_new2(_line, _col, "-"));
                        }
 
@@ -490,7 +490,6 @@ struct token *nexttoken(void)
 
                case STATE_NUM:
                        /* FIXME: e, E may be in the middle, (u|U)(l|L|ll|LL) or vice versa may be at the end */
-
                        if(c >= '0' && c <= '9' || c == '.') {
                                str_appendc(tok->value, c);
                        } else {
@@ -513,43 +512,8 @@ int main(int argc, char *argv[])
        ret_val = 0;
 
        while((tok = nexttoken())) {
-               printf("Token at %d:%d: %s\n", tok->line, tok->column, str_value(tok->value));
-       }
-#if 0
-       while(_state != STATE_DONE) {
-               printf("_state = %d\n", _state);
-
-               switch(_state) {
-               case STATE_NONE:
-                       _state = none();
-                       break;
-
-               case STATE_COMMENT:
-                       _state = comment();
-                       break;
-
-               case STATE_OP:
-                       _state = op();
-                       break;
-
-               default:
-                       _state = STATE_DONE;
-                       break;
-               }
-       }
-
-       if(!tokens) {
-               printf("No tokens\n");
-       }
-
-       for(litem = tokens; litem; litem = litem->next) {
-               struct token *t;
-
-               t = (struct token*)litem->data;
-
-               printf("%s token at line %d:%d\n", token_typestr(t->type), t->line, t->column);
+               printf("Token at %4d:%3d: \"%s\"\n", tok->line, tok->column, str_value(tok->value));
        }
-#endif
 
        return(ret_val);
 }