summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-02-20 00:15:11 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-02-20 00:15:11 -0800
commit4d9e079e826c9b51b610260564111fa8385f7581 (patch)
tree13a4e3a16efd510b3b15a2ce55cf3caeb00857aa
parentMerge branch 'zj/term-columns' (diff)
parentmake lineno_width() from blame reusable for others (diff)
downloadtgif-4d9e079e826c9b51b610260564111fa8385f7581.tar.xz
Merge branch 'zj/decimal-width'
* zj/decimal-width: make lineno_width() from blame reusable for others Conflicts: cache.h pager.c
-rw-r--r--builtin/blame.c18
-rw-r--r--cache.h1
-rw-r--r--pager.c12
3 files changed, 16 insertions, 15 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 01956c8081..b35bd6249d 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);
}
/*
diff --git a/cache.h b/cache.h
index 3a8e1258e7..422c5cfcb3 100644
--- a/cache.h
+++ b/cache.h
@@ -1178,6 +1178,7 @@ extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
extern int term_columns(void);
+extern int decimal_width(int);
extern const char *editor_program;
extern const char *askpass_program;
diff --git a/pager.c b/pager.c
index b7909678f4..05584dead6 100644
--- a/pager.c
+++ b/pager.c
@@ -147,3 +147,15 @@ int term_columns(void)
return term_columns_at_startup;
}
+
+/*
+ * 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;
+}