diff options
author | unknown <vva@eagle.mysql.r18.ru> | 2002-12-15 22:30:26 +0400 |
---|---|---|
committer | unknown <vva@eagle.mysql.r18.ru> | 2002-12-15 22:30:26 +0400 |
commit | 63648a06529b7132ec057896a4cbf48f8c8cd590 (patch) | |
tree | 66c0123e936a3c69df9b1bd20f6751eebd485bc4 /sql/gen_lex_hash.cc | |
parent | e0e19fc20e3646221485ff79365a9ecd375a8921 (diff) | |
download | mariadb-git-63648a06529b7132ec057896a4cbf48f8c8cd590.tar.gz |
adding check for duplicated symbols
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/gen_lex_hash.cc')
-rw-r--r-- | sql/gen_lex_hash.cc | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 7daab228093..7ae28e0ce77 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -200,19 +200,21 @@ void insert_sql_functions() } } -void generate_find_structs() +void calc_length() { - root_by_len= 0; - max_len=0; - size_t i; - SYMBOL *cur, *end= symbols + array_elements(symbols); for (cur= symbols; cur < end; cur++) cur->length=(uchar) strlen(cur->name); end= sql_functions + array_elements(sql_functions); for (cur= sql_functions; cur<end; cur++) cur->length=(uchar) strlen(cur->name); - +} + +void generate_find_structs() +{ + root_by_len= 0; + max_len=0; + insert_symbols(); root_by_len2= root_by_len; @@ -351,6 +353,45 @@ static int get_options(int argc, char **argv) return(0); } +int check_dup_symbols(SYMBOL *s1, SYMBOL *s2) +{ + if (s1->length!=s2->length || strncmp(s1->name,s2->name,s1->length)) + return 0; + + const char *err_tmpl= "\ngen_lex_hash fatal error : \ +Unfortunately gen_lex_hash can not generate a hash,\n since \ +your lex.h has duplicate definition for a symbol \"%s\"\n\n"; + printf (err_tmpl,s1->name); + fprintf (stderr,err_tmpl,s1->name); + + return 1; +} + +int check_duplicates() +{ + SYMBOL *cur1, *cur2, *s_end, *f_end; + + s_end= symbols + array_elements(symbols); + f_end= sql_functions + array_elements(sql_functions); + + for (cur1= symbols; cur1<s_end; cur1++) + { + for (cur2= cur1+1; cur2<s_end; cur2++) + if (check_dup_symbols(cur1,cur2)) + return 1; + for (cur2= sql_functions; cur2<f_end; cur2++) + if (check_dup_symbols(cur1,cur2)) + return 1; + } + + for (cur1= sql_functions; cur1<f_end; cur1++) + for (cur2= cur1+1; cur2< f_end; cur2++) + if (check_dup_symbols(cur1,cur2)) + return 1; + + return 0; +} + int main(int argc,char **argv) { MY_INIT(argv[0]); @@ -376,6 +417,11 @@ int main(int argc,char **argv) a perfect\nhash function */\n\n"); printf("#include \"lex.h\"\n\n"); + calc_length(); + + if (check_duplicates()) + exit(1); + generate_find_structs(); print_find_structs(); |