| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
|---|
| 3 | | - * Released under the terms of the GNU GPL v2.0. |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | +#include <ctype.h> |
|---|
| 7 | +#include <errno.h> |
|---|
| 6 | 8 | #include <stdio.h> |
|---|
| 7 | 9 | #include <stdlib.h> |
|---|
| 8 | 10 | #include <string.h> |
|---|
| .. | .. |
|---|
| 11 | 13 | |
|---|
| 12 | 14 | #define DEBUG_EXPR 0 |
|---|
| 13 | 15 | |
|---|
| 14 | | -static int expr_eq(struct expr *e1, struct expr *e2); |
|---|
| 15 | 16 | static struct expr *expr_eliminate_yn(struct expr *e); |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | struct expr *expr_alloc_symbol(struct symbol *sym) |
|---|
| .. | .. |
|---|
| 248 | 249 | * equals some operand in the other (operands do not need to appear in the same |
|---|
| 249 | 250 | * order), recursively. |
|---|
| 250 | 251 | */ |
|---|
| 251 | | -static int expr_eq(struct expr *e1, struct expr *e2) |
|---|
| 252 | +int expr_eq(struct expr *e1, struct expr *e2) |
|---|
| 252 | 253 | { |
|---|
| 253 | 254 | int res, old_count; |
|---|
| 254 | 255 | |
|---|
| .. | .. |
|---|
| 987 | 988 | k_string, |
|---|
| 988 | 989 | k_signed, |
|---|
| 989 | 990 | k_unsigned, |
|---|
| 990 | | - k_invalid |
|---|
| 991 | 991 | }; |
|---|
| 992 | 992 | |
|---|
| 993 | 993 | union string_value { |
|---|
| .. | .. |
|---|
| 1018 | 1018 | val->u = strtoull(str, &tail, 16); |
|---|
| 1019 | 1019 | kind = k_unsigned; |
|---|
| 1020 | 1020 | break; |
|---|
| 1021 | | - case S_STRING: |
|---|
| 1022 | | - case S_UNKNOWN: |
|---|
| 1021 | + default: |
|---|
| 1023 | 1022 | val->s = strtoll(str, &tail, 0); |
|---|
| 1024 | 1023 | kind = k_signed; |
|---|
| 1025 | 1024 | break; |
|---|
| 1026 | | - default: |
|---|
| 1027 | | - return k_invalid; |
|---|
| 1028 | 1025 | } |
|---|
| 1029 | 1026 | return !errno && !*tail && tail > str && isxdigit(tail[-1]) |
|---|
| 1030 | 1027 | ? kind : k_string; |
|---|
| .. | .. |
|---|
| 1080 | 1077 | |
|---|
| 1081 | 1078 | if (k1 == k_string || k2 == k_string) |
|---|
| 1082 | 1079 | res = strcmp(str1, str2); |
|---|
| 1083 | | - else if (k1 == k_invalid || k2 == k_invalid) { |
|---|
| 1084 | | - if (e->type != E_EQUAL && e->type != E_UNEQUAL) { |
|---|
| 1085 | | - printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2); |
|---|
| 1086 | | - return no; |
|---|
| 1087 | | - } |
|---|
| 1088 | | - res = strcmp(str1, str2); |
|---|
| 1089 | | - } else if (k1 == k_unsigned || k2 == k_unsigned) |
|---|
| 1080 | + else if (k1 == k_unsigned || k2 == k_unsigned) |
|---|
| 1090 | 1081 | res = (lval.u > rval.u) - (lval.u < rval.u); |
|---|
| 1091 | 1082 | else /* if (k1 == k_signed && k2 == k_signed) */ |
|---|
| 1092 | 1083 | res = (lval.s > rval.s) - (lval.s < rval.s); |
|---|