diff options
Diffstat (limited to 'opcodes/disassemble.c')
-rw-r--r-- | opcodes/disassemble.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c index 1b1524247ae..eef06584f43 100644 --- a/opcodes/disassemble.c +++ b/opcodes/disassemble.c @@ -20,6 +20,7 @@ #include "sysdep.h" #include "dis-asm.h" +#include "safe-ctype.h" #ifdef ARCH_all #define ARCH_aarch64 @@ -649,7 +650,76 @@ disassemble_init_for_target (struct disassemble_info * info) disassemble_init_powerpc (info); break; #endif +#ifdef ARCH_s390 + case bfd_arch_s390: + disassemble_init_s390 (info); + break; +#endif default: break; } } + +/* Remove whitespace and consecutive commas from OPTIONS. */ + +char * +remove_whitespace_and_extra_commas (char *options) +{ + char *str; + size_t i, len; + + if (options == NULL) + return NULL; + + /* Strip off all trailing whitespace and commas. */ + for (len = strlen (options); len > 0; len--) + { + if (!ISSPACE (options[len - 1]) && options[len - 1] != ',') + break; + options[len - 1] = '\0'; + } + + /* Convert all remaining whitespace to commas. */ + for (i = 0; options[i] != '\0'; i++) + if (ISSPACE (options[i])) + options[i] = ','; + + /* Remove consecutive commas. */ + for (str = options; *str != '\0'; str++) + if (*str == ',' && (*(str + 1) == ',' || str == options)) + { + char *next = str + 1; + while (*next == ',') + next++; + len = strlen (next); + if (str != options) + str++; + memmove (str, next, len); + next[len - (size_t)(next - str)] = '\0'; + } + return (strlen (options) != 0) ? options : NULL; +} + +/* Like STRCMP, but treat ',' the same as '\0' so that we match + strings like "foobar" against "foobar,xxyyzz,...". */ + +int +disassembler_options_cmp (const char *s1, const char *s2) +{ + unsigned char c1, c2; + + do + { + c1 = (unsigned char) *s1++; + if (c1 == ',') + c1 = '\0'; + c2 = (unsigned char) *s2++; + if (c2 == ',') + c2 = '\0'; + if (c1 == '\0') + return c1 - c2; + } + while (c1 == c2); + + return c1 - c2; +} |