aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-02-12 15:16:20 +0100
committerJunio C Hamano <gitster@pobox.com>2012-02-14 16:16:19 -0800
commitec7ff5ba272b565ed093a98dc13dd5cd26aeac92 (patch)
tree9039325114378101cc6f922337a9ab33e3adb3bf /builtin
parent58d4203aa617293d1dc3746a1ea33d84eb766e0f (diff)
downloadgit-ec7ff5ba272b565ed093a98dc13dd5cd26aeac92.tar.gz
git-ec7ff5ba272b565ed093a98dc13dd5cd26aeac92.tar.xz
make lineno_width() from blame reusable for others
builtin/blame.c has a helper function to compute how many columns we need to show a line-number, whose implementation is reusable as a more generic helper function to count the number of columns necessary to show any cardinal number. Rename it to decimal_width(), move it to pager.c and export it for use by future callers. Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/blame.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 5a67c202f..f028e8aec 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1829,18 +1829,6 @@ static int read_ancestry(const char *graft_file)
}
/*
- * How many columns do we need to show line numbers in decimal?
- */
-static int lineno_width(int lines)
-{
- int i, width;
-
- for (width = 1, i = 10; i <= lines; width++)
- i *= 10;
- return width;
-}
-
-/*
* How many columns do we need to show line numbers, authors,
* and filenames?
*/
@@ -1880,9 +1868,9 @@ static void find_alignment(struct scoreboard *sb, int *option)
if (largest_score < ent_score(sb, e))
largest_score = ent_score(sb, e);
}
- max_orig_digits = lineno_width(longest_src_lines);
- max_digits = lineno_width(longest_dst_lines);
- max_score_digits = lineno_width(largest_score);
+ max_orig_digits = decimal_width(longest_src_lines);
+ max_digits = decimal_width(longest_dst_lines);
+ max_score_digits = decimal_width(largest_score);
}
/*