}
// end of hack
- int pattern_index = 0;
- int table_index = 0;
- char pattern[22]; // 20 + 1 for pattern[20], + 1 for '\0'
-
- number_index = 1;
- unit_index = 1; // entries at index 0 are sentinels
-
// construct "pattern" from "data"
+ size_t const pattern_max_size = 20;
+ string pattern;
while (!isEndOfData(buffer)) {
- if (pattern_index > (sizeof(pattern) - 2))
+ if (pattern.size() > pattern_max_size)
return false;
- pattern[pattern_index] = nextToken(buffer);
- if (pattern[pattern_index] == 'E')
+ char const c = nextToken(buffer);
+ if (c == 'E')
return false;
- ++pattern_index;
+ pattern.push_back(c);
}
- pattern[pattern_index] = '\0';
// search "pattern" in "table"
- table_index = 0;
- while (strcmp(pattern, table[table_index].pattern)) {
+ size_t table_index = 0;
+ while (pattern != table[table_index].pattern) {
++table_index;
if (!*table[table_index].pattern)
return false;