@@ -933,42 +933,42 @@ static Count_bin do_count(int lineno, count_context_t *ctxt,
933
933
/*
934
934
* See do_parse() for the purpose of this function.
935
935
*
936
- * The returned number of parses (called here "count") is a 32-bit
937
- * integer. However, this count may sometimes be very big - much more than
938
- * can be represented in 32-bits. In such a case it is just enough to know
939
- * that such an "overflow" occurred. Internally, big counts are clamped to
936
+ * The returned number of parses (called "count" here ) is a 32-bit
937
+ * integer. However, this count may sometimes be very big - much larger than
938
+ * can be represented in 32-bits. In such a case, it is just enough to know
939
+ * that such an "overflow" occurred. Internally, large counts are clamped to
940
940
* INT_MAX (2^31-1) - see parse_count_clamp() (we refer below to such
941
941
* values as "clamped"). If the top-level do_count() (the one that is
942
- * called from do_parse()) returns this value, it means such an overflow
942
+ * called from do_parse()) returns this value, it means that an overflow
943
943
* has occurred.
944
944
*
945
945
* The function uses a 64-bit signed integer as a count accumulator - named
946
946
* "total". The maximum value it can hold is 2^63-1. If it becomes greater
947
- * than INT_MAX, it is considered as a count overflow. A care should be
948
- * taken that this total itself would not overflow, else this detection
949
- * mechanism would be rendered useless . To that end, each value from which
950
- * this total is computed should be small enough so it would not overflow.
947
+ * than INT_MAX, it is considered as a count overflow. Care must be
948
+ * taken that this total itself does not overflow, else this detection
949
+ * mechanism would malfunction . To that end, each value from which
950
+ * this total is computed must be small enough so it does not overflow.
951
951
*
952
952
* The function has 4 code sections to calculate the count. Each of them,
953
953
* when entered, returns a value which is clamped (or doesn't need to be
954
954
* clamped). The are marked in the code with "Path 1a", "Path 1b",
955
955
* "Path 2", and "Path 3".
956
956
*
957
957
* Path 1a, Path 1b: If there is a possible linkage between the given
958
- * words, return 1, else return 0. Here a count overflow cannot occur.
958
+ * words, return 1, else return 0. Here, a count overflow cannot occur.
959
959
*
960
- * Path 2: The total accumulate the result of the do_count() invocations
960
+ * Path 2: The total accumulates the result of the do_count() invocations
961
961
* that are done in a loop. The upper bound on the number of iterations is
962
- * twice (out loop) the maximum number of word disjuncts ) inner loop).
962
+ * twice (outer loop) the maximum number of word disjuncts ( inner loop).
963
963
* Assuming no more than 2^31 disjuncts per word, and considering that
964
964
* each value is a result of do_count() which is clamped, the total is
965
965
* less than (2*2^31)*(2^31`-1), which is less than 2^63-1, and hence just
966
966
* needs to be clamped before returning.
967
967
*
968
968
* Path 3: The total is calculated as a sum of series of multiplications.
969
969
* To prevent its overflow, we ensure that each term (including the total
970
- * itself) would not be greater than INT_MAX (2^31-1), so the result will
971
- * not be more than (2^31-1)+((2^31-1)*(2^31-1)) which is less than
970
+ * itself) would not be greater than INT_MAX (2^31-1). Then the result will
971
+ * not be more than (2^31-1)+((2^31-1)*(2^31-1)), which is less than
972
972
* 2^63-1. In this path, each multiplication term that may be greater then
973
973
* INT_MAX (leftcount and rightcount) is clamped before the
974
974
* multiplication, and the total is clamped after the multiplication.
@@ -1419,11 +1419,12 @@ static Count_bin do_count(
1419
1419
* we know that the true total is zero. So we don't
1420
1420
* bother counting the other term at all, in that case. */
1421
1421
1422
- /* To enable 31-bit overflow detection, total, leftcount and
1423
- * rightcount are signed 64-bit, and are , a clamped cached
1424
- * value, or are clamped below before they are used. total is
1425
- * initially 0 and is clamped at the end of each iteration.
1426
- * So the result will not be more than (2^31-1)+((2^31-1)*(2^31-1))
1422
+ /* To enable 31-bit overflow detection, `total`, `leftcount`
1423
+ * and `rightcount` are signed 64-bit, and are clamped cached
1424
+ * values, or are clamped below before they are used. `total`
1425
+ * is initially 0 and is clamped at the end of each iteration.
1426
+ * So the result will never be more than
1427
+ * (2^31-1)+((2^31-1)*(2^31-1)),
1427
1428
* which is less than 2^63-1. */
1428
1429
if (leftpcount &&
1429
1430
(!lcnt_optimize || rightpcount || (0 != hist_total (& l_bnr ))))
0 commit comments