aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-08-26 09:21:46 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-08-26 09:25:19 -0400
commit2073c641b43e1310784dc40aef32f71119313bdc (patch)
treebccf5bdc54bf71091cd856eff6dee43c156d1483 /src
parenta772624b1d6b47ac00384901e1753f1d34b0cd10 (diff)
downloadpostgresql-2073c641b43e1310784dc40aef32f71119313bdc.tar.gz
postgresql-2073c641b43e1310784dc40aef32f71119313bdc.zip
pg_test_timing: Some NLS fixes
The string "% of total" was marked by xgettext to be a c-format, but it is actually not, so mark up the source to prevent that. Compute the column widths of the final display dynamically based on the translated strings, so that translations don't mess up the display accidentally.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_test_timing/pg_test_timing.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/bin/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c
index 2f1ab7cd608..6e2fd1ab8c7 100644
--- a/src/bin/pg_test_timing/pg_test_timing.c
+++ b/src/bin/pg_test_timing/pg_test_timing.c
@@ -172,13 +172,22 @@ output(uint64 loop_count)
{
int64 max_bit = 31,
i;
+ char *header1 = _("< us");
+ char *header2 = /* xgettext:no-c-format */ _("% of total");
+ char *header3 = _("count");
+ int len1 = strlen(header1);
+ int len2 = strlen(header2);
+ int len3 = strlen(header3);
/* find highest bit value */
while (max_bit > 0 && histogram[max_bit] == 0)
max_bit--;
printf(_("Histogram of timing durations:\n"));
- printf("%6s %10s %10s\n", _("< us"), _("% of total"), _("count"));
+ printf("%*s %*s %*s\n",
+ Max(6, len1), header1,
+ Max(10, len2), header2,
+ Max(10, len3), header3);
for (i = 0; i <= max_bit; i++)
{
@@ -186,7 +195,9 @@ output(uint64 loop_count)
/* lame hack to work around INT64_FORMAT deficiencies */
snprintf(buf, sizeof(buf), INT64_FORMAT, histogram[i]);
- printf("%6ld %9.5f %10s\n", 1l << i,
- (double) histogram[i] * 100 / loop_count, buf);
+ printf("%*ld %*.5f %*s\n",
+ Max(6, len1), 1l << i,
+ Max(10, len2) - 1, (double) histogram[i] * 100 / loop_count,
+ Max(10, len3), buf);
}
}