From 3e890047742a6c96a421700d536a260bcc12a8ec Mon Sep 17 00:00:00 2001 From: Geoffrey Keating Date: Thu, 14 Jun 2001 20:38:42 +0000 Subject: [PATCH] Index: opcodes/ChangeLog 2001-06-13 Geoffrey Keating * cgen-asm.c (cgen_parse_keyword): When looking for the boundaries of a keyword, allow any special characters that are actually in one of the allowed keyword. * cgen-opc.c (cgen_keyword_add): Add any special characters to the nonalpha_chars field. Index: cgen/ChangeLog 2001-06-13 Geoffrey Keating * desc.scm ( 'gen-defn): Add extra zero into CGEN_KEYWORD_ENTRY initializers. Index: include/opcode/ChangeLog 2001-06-13 Geoffrey Keating * cgen.h (cgen_keyword): Add nonalpha_chars field. --- include/opcode/ChangeLog | 4 ++++ include/opcode/cgen.h | 5 +++++ opcodes/ChangeLog | 8 ++++++++ opcodes/cgen-asm.c | 15 +++++++-------- opcodes/cgen-opc.c | 16 ++++++++++++++++ 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog index ed883d0..71c2dac 100644 --- a/include/opcode/ChangeLog +++ b/include/opcode/ChangeLog @@ -1,3 +1,7 @@ +2001-06-14 Geoffrey Keating + + * cgen.h (cgen_keyword): Add nonalpha_chars field. + 2001-05-23 Thiemo Seufer * mips.h (CPU_R12000): Define. diff --git a/include/opcode/cgen.h b/include/opcode/cgen.h index 8d3c310..c13c4d9 100644 --- a/include/opcode/cgen.h +++ b/include/opcode/cgen.h @@ -513,6 +513,11 @@ typedef struct cgen_keyword /* Pointer to null keyword "" entry if present. */ const CGEN_KEYWORD_ENTRY *null_entry; + + /* String containing non-alphanumeric characters used + in keywords. + At present, the highest number of entries used is 1. */ + char nonalpha_chars[8]; } CGEN_KEYWORD; /* Structure used for searching. */ diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index b32274d..3839166 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,11 @@ +2001-06-14 Geoffrey Keating + + * cgen-asm.c (cgen_parse_keyword): When looking for the + boundaries of a keyword, allow any special characters + that are actually in one of the allowed keyword. + * cgen-opc.c (cgen_keyword_add): Add any special characters + to the nonalpha_chars field. + 2001-06-12 Martin Schwidefsky * s390-opc.c: Add lgh instruction. diff --git a/opcodes/cgen-asm.c b/opcodes/cgen-asm.c index a8d6ff8..315b802 100644 --- a/opcodes/cgen-asm.c +++ b/opcodes/cgen-asm.c @@ -207,17 +207,16 @@ cgen_parse_keyword (cd, strp, keyword_table, valuep) char buf[256]; const char *p,*start; - p = start = *strp; + if (keyword_table->name_hash_table == NULL) + (void) cgen_keyword_search_init (keyword_table, NULL); - /* Allow any first character. - Note that this allows recognizing ",a" for the annul flag in sparc - even though "," is subsequently not a valid keyword char. */ - if (*p) - ++p; + p = start = *strp; - /* Now allow letters, digits, and _. */ + /* Allow letters, digits, and any special characters. */ while (((p - start) < (int) sizeof (buf)) - && (isalnum ((unsigned char) *p) || *p == '_')) + && *p + && (isalnum ((unsigned char) *p) + || strchr (keyword_table->nonalpha_chars, *p))) ++p; if (p - start >= (int) sizeof (buf)) diff --git a/opcodes/cgen-opc.c b/opcodes/cgen-opc.c index 7e958e7..f159943 100644 --- a/opcodes/cgen-opc.c +++ b/opcodes/cgen-opc.c @@ -118,6 +118,7 @@ cgen_keyword_add (kt, ke) CGEN_KEYWORD_ENTRY *ke; { unsigned int hash; + size_t i; if (kt->name_hash_table == NULL) build_keyword_hash_tables (kt); @@ -132,6 +133,21 @@ cgen_keyword_add (kt, ke) if (ke->name[0] == 0) kt->null_entry = ke; + + for (i = 0; i < strlen (ke->name); i++) + if (! isalnum ((unsigned char) ke->name[i]) + && ! strchr (kt->nonalpha_chars, ke->name[i])) + { + size_t idx = strlen (kt->nonalpha_chars); + + /* If you hit this limit, please don't just + increase the size of the field, instead + look for a better algorithm. */ + if (idx >= sizeof (kt->nonalpha_chars) - 1) + abort (); + kt->nonalpha_chars[idx] = ke->name[i]; + kt->nonalpha_chars[idx+1] = 0; + } } /* FIXME: Need function to return count of keywords. */ -- 2.7.4