static ASTPtr generateCCs(std::vector<ConsistentContent>* ccs, const char* format, const char*** wordSourcesPtr, const LengthFunc** lengthFuncsPtr, va_list args) { ccs->clear(); std::string evaluatedFormat; vsprintf(&evaluatedFormat, format, args); const char* f_begin = evaluatedFormat.c_str(); const char* f_at = f_begin; ASTPtr root; try { //printf("\n\n%s\n", format); root = parseFormat(&f_at, wordSourcesPtr, lengthFuncsPtr); root->convertLLSharesToLength(); root->computeStartEndCols(0, root->getFixedLength()); std::vector<FillerPtr> topFillersStack, bottomFillersStack; root->flatten(root, root, ccs, true, &topFillersStack, &bottomFillersStack); //root->print(); //printf("\n"); for (ConsistentContent& cc : *ccs) { cc.generateCCLines(); } root->computeNumContentLines(); root->computeNumTotalLines(true); root->computeBlockVerticalFillersShares(); //printf("\n"); for (ConsistentContent& cc : *ccs) { /*printf("\n"); cc.print(); printf("\n"); printf("content: %d fixed: %d total: %d\n", cc.srcAst->numContentLines, cc.srcAst->numFixedLines, cc.srcAst->numTotalLines);*/ cc.generateLinesChars(root->numTotalLines); } //printf("\n\n"); } catch (DSLException& e) { fprintf(stderr, "%s\n", f_begin); for (int i = 0; i < e.f_at - f_begin; ++i) { fputc(' ', stderr); } fprintf(stderr, "^\n"); fprintf(stderr, "Error at %d: %s\n", e.f_at - f_begin, e.what()); return ASTPtr(); } return root; }