/* Entry is eaten. * No check is done if entry->tuple is a member of sym->set ! * This has to be done before. */ void symbol_add_entry(Symbol* sym, Entry* entry) { const Tuple* tuple; assert(symbol_is_valid(sym)); assert(entry_is_valid(entry)); assert(sym->used <= sym->size); if (sym->used == sym->size) { sym->size += sym->extend; sym->extend += sym->extend; sym->entry = realloc( sym->entry, (size_t)sym->size * sizeof(*sym->entry)); assert(sym->entry != NULL); } assert(sym->used < sym->size); tuple = entry_get_tuple(entry); /* There is no index set for the internal symbol. */ assert(!strcmp(sym->name, SYMBOL_NAME_INTERNAL) || set_lookup(sym->set, tuple)); if (hash_has_entry(sym->hash, tuple)) { if (stmt_trigger_warning(166)) { fprintf(stderr, "--- Warning 166: Duplicate element "); tuple_print(stderr, tuple); fprintf(stderr, " for symbol %s rejected\n", sym->name); } entry_free(entry); } else { /* Falls noch nicht geschehen, legen wir hier den Typ des * Symbols fest. */ if ((sym->type == SYM_ERR) && (sym->used == 0)) sym->type = entry_get_type(entry); assert(sym->type != SYM_ERR); hash_add_entry(sym->hash, entry); sym->entry[sym->used] = entry; sym->used++; } }
static char* get_line(char** buf, int* size, const MFP* fp, int* lineno) { Bool in_string = FALSE; int cnt = 0; int c; for(;;) { assert(cnt <= *size); if (cnt == *size - 1) { *size += BUF_EXT; *buf = realloc(*buf, (size_t)*size); } assert(*buf != NULL); c = mio_getc(fp); if (in_string && ((c == EOF) || c == '\n')) { fprintf(stderr, "*** Error 161: Line %d: Unterminated string\n", *lineno); zpl_exit(EXIT_FAILURE); } if (c == EOF) { if (cnt > 0) { (*buf)[cnt] = '\0'; if (stmt_trigger_warning(162)) fprintf(stderr, "--- Warning 162: Line %d: Trailing \"%.20s\" ignored\n", *lineno, *buf); } return NULL; } if (c == '\n') { c = ' '; (*lineno)++; } if (iscntrl(c)) c = ' '; /* Skip leading white space */ if (cnt == 0 && isspace(c)) continue; if (c == '"') in_string = !in_string; /* Remove comments */ if (!in_string && (c == '#')) { skip_comment(fp, lineno); /* do { c = mio_getc(fp); } while((c != EOF) && (c != '\n')); (*lineno)++; */ continue; } (*buf)[cnt++] = (char)c; if (!in_string && (c == ';')) break; } (*buf)[cnt] = '\0'; return *buf; }