linkedList* variableOrdering(graph *g,int choice){ item *currItem; linkedList *orderedList; vertex *v; int i; breakCycles(g); resetWeights(g); computeWeights(g); genericSuccessorsOrdering(g, choice); orderByWeights(g->vertices); resetVisited(g); orderedList= newLinkedList(); currItem = (g-> vertices)->head; while (currItem!= NULL) { if ((currItem->vert)->visited == 0) visit(currItem->vert,orderedList); currItem = currItem->next; } return orderedList; }
void DependencyDigraph::checkForCycles(InvariantContainer& invars) { cycleCounter = 1; timestampCounter = 0; while (cycleCounter != 0) { cycleCounter = 0; invariantsCycles.clear(); // brokenCycles.clear(); // brokenInvariants.clear(); for (unsigned i = 0; i < invars.size(); i++) { std::vector<unsigned > cycles; // = new std::vector<unsigned >(); invariantsCycles.push_back(cycles); } // assert(invariantsCycles.size() != 0); // brokenCycles.resize(invars.size(), false); for (invariant inv : invars) { std::shared_ptr<invariantNode> in = invariant_nodes.at(inv->getID()); if (in->timestamp == 0) { DFS(in); } assert(inv->getTimestamp() != 0); } std::cout << "number of cycles " << cycleCounter << std::endl; if (cycleCounter != 0) { breakCycles(); } // std::cout << "invars size " << invars.size() << " broken invariants size " << brokenInvariants.size() << std::endl; for (invariant inv : invars) { if (inv->isBroken()) { // if (brokenInvariants.at(inv->getID())) { continue; } std::shared_ptr<invariantNode> in = invariant_nodes.at(inv->getID()); in->timestamp = 0; in->lowestLink = 0; assert(!invariant_nodes.at(inv->getID())->inCurrentSSC); } // debug; } }
static void removeRedundantProperties(CSSSheet *sheet) { // Remove any properties set on a style that have the same value as the corresponding property // on the parent style. This is necessary because CSS doesn't support style inheritance (in // the sense of Word & ODF's styles), so when we save out a HTML file, every style has all // properties of its ancestors. After reading in a HTML file for the purposes of updating the // original Word or ODF style, we don't want these extra property settings to remain, so that // we can avoid adding spurious extra redundant property settings to the original file. breakCycles(sheet); const char **sortedSelectors = reverseTopologicalSortedSelectors(sheet); for (size_t selIndex = 0; sortedSelectors[selIndex]; selIndex++) { const char *selector = sortedSelectors[selIndex]; CSSStyle *child = CSSSheetLookupSelector(sheet,selector,0,0); CSSStyle *parent = CSSSheetGetStyleParent(sheet,child); if (parent == NULL) continue; const char **allSuffixes = CSSStyleCopySuffixes(child); for (int suffixIndex = 0; allSuffixes[suffixIndex]; suffixIndex++) { const char *suffix = allSuffixes[suffixIndex]; int isCell = !strcmp(suffix," > * > tr > td"); CSSProperties *childProperties = CSSStyleRuleForSuffix(child,suffix); CSSProperties *parentProperties = CSSStyleRuleForSuffix(parent,suffix); const char **allNames = CSSPropertiesCopyNames(childProperties); for (int nameIndex = 0; allNames[nameIndex]; nameIndex++) { const char *name = allNames[nameIndex]; // In docx's styles.xml, the tblCellMar values in table styles are not inherited // (this seems like a bug in word, as isn't inconsistent with all other properties) // So keep these ones. if (isCell && DFStringHasPrefix(name,"padding-")) continue; const char *childVal = CSSGet(childProperties,name); const char *parentVal = CSSGet(parentProperties,name); if ((childVal != NULL) && (parentVal != NULL) && DFStringEquals(childVal,parentVal)) CSSPut(childProperties,name,NULL); } free(allNames); } free(allSuffixes); } free(sortedSelectors); }