Unified · Split
| @@ -997,11 +997,30 @@ ST_FUNC void tok_str_add_tok(TokenString *s) · 996 unmodified lines | ||
| 997 | 997 | } \ |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | +static int macro_is_equal(const int *a, const int *b) | |
| 1001 | +{ | |
| 1002 | + char buf[STRING_MAX_SIZE + 1]; | |
| 1003 | + CValue cv; | |
| 1004 | + int t; | |
| 1005 | + while (*a && *b) { | |
| 1006 | + TOK_GET(t, a, cv); | |
| 1007 | + pstrcpy(buf, sizeof buf, get_tok_str(t, &cv)); | |
| 1008 | + TOK_GET(t, b, cv); | |
| 1009 | + if (strcmp(buf, get_tok_str(t, &cv))) | |
| 1010 | + return 0; | |
| 1011 | + } | |
| 1012 | + return !(*a || *b); | |
| 1013 | +} | |
| 1014 | + | |
| 1000 | 1015 | /* defines handling */ |
| 1001 | 1016 | ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg) |
| 1002 | 1017 | { |
| 1003 | 1018 | Sym *s; |
| 1004 | 1019 | |
| 1020 | + s = define_find(v); | |
| 1021 | + if (s && !macro_is_equal(s->d, str)) | |
| 1022 | + warning("%s redefined", get_tok_str(v, NULL)); | |
| 1023 | + | |
| 1005 | 1024 | s = sym_push2(&define_stack, v, macro_type, 0); |
| 1006 | 1025 | s->d = str; |
| 1007 | 1026 | s->next = first_arg; |