static void cmt_trim_whitespace(unc_text& line, bool in_preproc) { /* Remove trailing whitespace on the line */ while ((line.size() > 0) && ((line.back() == ' ') || (line.back() == '\t'))) { line.pop_back(); } /* If in a preproc, shift any bs-nl back to the comment text */ if (in_preproc && (line.size() > 1) && (line.back() == '\\')) { bool do_space = false; /* If there was any space before the backslash, change it to 1 space */ line.pop_back(); while ((line.size() > 0) && ((line.back() == ' ') || (line.back() == '\t'))) { do_space = true; line.pop_back(); } if (do_space) { line.append(' '); } line.append('\\'); } }
/** * This renders the #if condition to a string buffer. */ static void generate_if_conditional_as_text(unc_text& dst, chunk_t *ifdef) { chunk_t *pc; int column = -1; dst.clear(); for (pc = ifdef; pc != NULL; pc = chunk_get_next(pc)) { if (column == -1) { column = pc->column; } if ((pc->type == CT_NEWLINE) || (pc->type == CT_COMMENT_MULTI) || (pc->type == CT_COMMENT_CPP)) { break; } else if (pc->type == CT_NL_CONT) { dst += ' '; column = -1; } else if ((pc->type == CT_COMMENT) || (pc->type == CT_COMMENT_EMBED)) { } else // if (pc->type == CT_JUNK) || else { int spacing; for (spacing = pc->column - column; spacing > 0; spacing--) { dst += ' '; column++; } dst.append(pc->str); column += pc->len(); } } }