+ context.program_ = program;
+
+ size_t offset(0);
+
+ // XXX: totalling the probable occurrences and sorting by them would improve the result
+ for (CYIdentifierAddressVector::const_iterator i(rename_.begin()); i != rename_.end(); ++i, ++offset) {
+ const char *name;
+
+ if (context.options_.verbose_)
+ name = apr_psprintf(context.pool_, "$%"APR_SIZE_T_FMT"", offset);
+ else {
+ char id[8];
+ id[7] = '\0';
+
+ id:
+ unsigned position(7), local(offset + 1);
+
+ do {
+ unsigned index(local % 53);
+ local /= 53;
+ id[--position] = index == 0 ? '0' : index < 27 ? index - 1 + 'a' : index - 27 + 'A';
+ } while (local != 0);
+
+ if (external_.find(id + position) != external_.end()) {
+ ++offset;
+ goto id;
+ }
+
+ name = apr_pstrmemdup(context.pool_, id + position, 7 - position);
+ // XXX: at some point, this could become a keyword
+ }
+
+ for (CYIdentifier *identifier(*i); identifier != NULL; identifier = identifier->next_)
+ identifier->Set(name);
+ }