struct symbol *elm;
struct symbol *new_elm;
- if(tab_lookup(tab,ident) != SYMNULL) {
+ if(tab_lookup(tab, ident) != SYMNULL) {
if(check) {
fprintf(stderr, "Feld doppelt vorhanden: \"%s\"\n", ident);
exit(3);
+ } else {
+ tab = tab_remove_symbol(tab, ident);
}
- tab = tab_remove_symbol(tab, ident);
}
new_elm = (struct symbol *) malloc(sizeof(struct symbol));
if(tab == SYMNULL) {
return SYMNULL;
}
-
- if(strcmp(elm->ident, ident) == 0) {
- return elm;
- }
-
- while(elm->next != SYMNULL) {
- elm = elm->next;
+
+ do {
if(strcmp(elm->ident, ident) == 0) {
return elm;
}
- }
+ elm = elm->next;
+ } while(elm != SYMNULL);
return SYMNULL;
}
{
struct symbol *elm = tab;
struct symbol *previous_elm = SYMNULL;
- struct symbol *new_elm;
-
- if(tab == SYMNULL) {
- return SYMNULL;
- }
while(elm != SYMNULL) {
if(strcmp(elm->ident, ident) == 0) {
if(previous_elm == SYMNULL) {
- new_elm = elm->next;
+ tab = elm->next;
} else {
previous_elm->next = elm->next;
- new_elm = tab;
}
(void)free(elm->ident);
(void)free(elm);
- return new_elm;
+ break;
}
previous_elm = elm;
elm = elm->next;