std::vector condense()

in misc/FontSurvey.cc [19:44]


std::vector<bool> condense(const std::vector<CHAR_INFO> &buf) {
    std::vector<bool> ret;
    size_t i = 0;
    while (i < buf.size()) {
        if (buf[i].Char.UnicodeChar == L' ' &&
                ((buf[i].Attributes & 0x300) == 0)) {
            // end of line
            break;
        } else if (i + 1 < buf.size() &&
                ((buf[i].Attributes & 0x300) == 0x100) &&
                ((buf[i + 1].Attributes & 0x300) == 0x200) &&
                buf[i].Char.UnicodeChar != L' ' &&
                buf[i].Char.UnicodeChar == buf[i + 1].Char.UnicodeChar) {
            // double-width
            ret.push_back(true);
            i += 2;
        } else if ((buf[i].Attributes & 0x300) == 0) {
            // single-width
            ret.push_back(false);
            i++;
        } else {
            ASSERT(false && "unexpected output");
        }
    }
    return ret;
}