Add seg name autoincrement to segmatch

Signed-off-by: Clifford Wolf <clifford@clifford.at>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
This commit is contained in:
Clifford Wolf 2017-11-15 03:43:05 +00:00 committed by Tim 'mithro' Ansell
parent 7238939c7b
commit c3234588e1
1 changed files with 11 additions and 1 deletions

View File

@ -26,6 +26,8 @@ vector<string> bit_ids_r, tag_ids_r;
typedef tuple<vector<bool>, vector<bool>, vector<bool>> segdata_t;
map<string, segdata_t> segdata;
map<string, int> segnamecnt;
static inline vector<bool> &segdata_bits(segdata_t &sd) { return std::get<0>(sd); }
static inline vector<bool> &segdata_tags1(segdata_t &sd) { return std::get<1>(sd); }
static inline vector<bool> &segdata_tags0(segdata_t &sd) { return std::get<2>(sd); }
@ -41,7 +43,15 @@ void read_input(std::istream &f, std::string filename)
{
f >> token;
token = filename + ":" + token;
assert(segdata.count(token) == 0);
while (segdata.count(token)) {
int idx = 1;
if (segnamecnt.count(token))
idx = segnamecnt.at(token);
segnamecnt[token] = idx + 1;
char buffer[64];
snprintf(buffer, 64, "-%d", idx);
token += buffer;
}
segptr = &segdata[token];
continue;
}