MCPcopy Create free account
hub / github.com/coreutils/coreutils / base_cost

Function base_cost

src/fmt.c:936–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

934 word THIS. */
935
936static COST
937base_cost (WORD *this)
938{
939 COST cost;
940
941 cost = LINE_COST;
942
943 if (this > word)
944 {
945 if ((this - 1)->period)
946 {
947 if ((this - 1)->final)
948 cost -= SENTENCE_BONUS;
949 else
950 cost += NOBREAK_COST;
951 }
952 else if ((this - 1)->punct)
953 cost -= PUNCT_BONUS;
954 else if (this > word + 1 && (this - 2)->final)
955 cost += WIDOW_COST ((this - 1)->length);
956 }
957
958 if (this->paren)
959 cost -= PAREN_BONUS;
960 else if (this->final)
961 cost += ORPHAN_COST (this->length);
962
963 return cost;
964}
965
966/* Return the component of the cost of breaking before word NEXT that
967 depends on LEN, the length of the line beginning there. */

Callers 1

fmt_paragraphFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected