summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 58d4203)
raw | patch | inline | side by side (parent: 58d4203)
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | |
Sun, 12 Feb 2012 14:16:20 +0000 (15:16 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 15 Feb 2012 00:16:19 +0000 (16:16 -0800) |
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>
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>
builtin/blame.c | patch | blob | history | |
cache.h | patch | blob | history | |
pager.c | patch | blob | history |
diff --git a/builtin/blame.c b/builtin/blame.c
index 5a67c202f06abeaa90a7547d78b536f7f2b9db24..f028e8aec82d0936951418f936123041c3b516ad 100644 (file)
--- a/builtin/blame.c
+++ b/builtin/blame.c
return 0;
}
-/*
- * 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?
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);
}
/*
index 9bd8c2d06c80c958b5f654fe16e7294883e49a30..24732e6caf8ba30b44a5aa5f40eb5756d164daf4 100644 (file)
--- a/cache.h
+++ b/cache.h
extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
+extern int decimal_width(int);
extern const char *editor_program;
extern const char *askpass_program;
index 975955ba82a0dbb128d6733090cd74c2b509ea81..96c07babbd7756a59fb5e891bf78f9c4396fed13 100644 (file)
--- a/pager.c
+++ b/pager.c
env = getenv("GIT_PAGER_IN_USE");
return env ? git_config_bool("GIT_PAGER_IN_USE", env) : 0;
}
+
+/*
+ * How many columns do we need to show this number in decimal?
+ */
+int decimal_width(int number)
+{
+ int i, width;
+
+ for (width = 1, i = 10; i <= number; width++)
+ i *= 10;
+ return width;
+}