MCPcopy Create free account
hub / github.com/SimHacker/micropolis / ChangeNodeToggleCount

Function ChangeNodeToggleCount

micropolis-activity/src/tk/tktxbtre.c:1860–1923  ·  view source on GitHub ↗
(nodePtr, tagPtr, delta)

Source from the content-addressed store, hash-verified

1858}
1859
1860
1861/*
1862 *----------------------------------------------------------------------
1863 *
1864 * ChangeNodeToggleCount --
1865 *
1866 * This procedure increments or decrements the toggle count for
1867 * a particular tag in a particular node and all its ancestors.
1868 *
1869 * Results:
1870 * None.
1871 *
1872 * Side effects:
1873 * The toggle count for tag is adjusted up or down by "delta" in
1874 * nodePtr.
1875 *
1876 *----------------------------------------------------------------------
1877 */
1878
1879static void
1880ChangeNodeToggleCount(nodePtr, tagPtr, delta)
1881 register Node *nodePtr; /* Node whose toggle count for a tag
1882 * must be changed. */
1883 TkTextTag *tagPtr; /* Information about tag. */
1884 int delta; /* Amount to add to current toggle
1885 * count for tag (may be negative). */
1886{
1887 register Summary *summaryPtr, *prevPtr;
1888
1889 /*
1890 * Iterate over the node and all of its ancestors.
1891 */
1892
1893 for ( ; nodePtr != NULL; nodePtr = nodePtr->parentPtr) {
1894 /*
1895 * See if there's already an entry for this tag for this node. If so,
1896 * perhaps all we have to do is adjust its count.
1897 */
1898
1899 for (prevPtr = NULL, summaryPtr = nodePtr->summaryPtr;
1900 summaryPtr != NULL;
1901 prevPtr = summaryPtr, summaryPtr = summaryPtr->nextPtr) {
1902 if (summaryPtr->tagPtr != tagPtr) {
1903 continue;
1904 }
1905 summaryPtr->toggleCount += delta;
1906 if (summaryPtr->toggleCount > 0) {
1907 goto nextAncestor;
1908 }
1909 if (summaryPtr->toggleCount < 0) {
1910 panic("ChangeNodeToggleCount: negative toggle count");
1911 }
1912
1913 /*
1914 * Zero count; must remove this tag from the list.
1915 */
1916
1917 if (prevPtr == NULL) {

Callers 2

TkBTreeDeleteCharsFunction · 0.85
AddToggleToLineFunction · 0.85

Calls 1

panicFunction · 0.85

Tested by

no test coverage detected