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

Function compute_number_width

src/wc.c:757–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755 get_input_fstatus optimizes. */
756
757ATTRIBUTE_PURE
758static int
759compute_number_width (idx_t nfiles, struct fstatus const *fstatus)
760{
761 int width = 1;
762
763 if (0 < nfiles && fstatus[0].failed <= 0)
764 {
765 int minimum_width = 1;
766 uintmax_t regular_total = 0;
767
768 for (idx_t i = 0; i < nfiles; i++)
769 if (! fstatus[i].failed)
770 {
771 if (!S_ISREG (fstatus[i].st.st_mode))
772 minimum_width = 7;
773 else if (ckd_add (&regular_total, regular_total,
774 fstatus[i].st.st_size))
775 {
776 regular_total = UINTMAX_MAX;
777 break;
778 }
779 }
780
781 for (; 10 <= regular_total; regular_total /= 10)
782 width++;
783 if (width < minimum_width)
784 width = minimum_width;
785 }
786
787 return width;
788}
789
790
791int

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected