Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2073c64

Browse files
committed
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.
1 parent a772624 commit 2073c64

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/bin/pg_test_timing/pg_test_timing.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,32 @@ output(uint64 loop_count)
172172
{
173173
int64 max_bit = 31,
174174
i;
175+
char *header1 = _("< us");
176+
char *header2 = /* xgettext:no-c-format */ _("% of total");
177+
char *header3 = _("count");
178+
int len1 = strlen(header1);
179+
int len2 = strlen(header2);
180+
int len3 = strlen(header3);
175181

176182
/* find highest bit value */
177183
while (max_bit > 0 && histogram[max_bit] == 0)
178184
max_bit--;
179185

180186
printf(_("Histogram of timing durations:\n"));
181-
printf("%6s %10s %10s\n", _("< us"), _("% of total"), _("count"));
187+
printf("%*s %*s %*s\n",
188+
Max(6, len1), header1,
189+
Max(10, len2), header2,
190+
Max(10, len3), header3);
182191

183192
for (i = 0; i <= max_bit; i++)
184193
{
185194
char buf[100];
186195

187196
/* lame hack to work around INT64_FORMAT deficiencies */
188197
snprintf(buf, sizeof(buf), INT64_FORMAT, histogram[i]);
189-
printf("%6ld %9.5f %10s\n", 1l << i,
190-
(double) histogram[i] * 100 / loop_count, buf);
198+
printf("%*ld %*.5f %*s\n",
199+
Max(6, len1), 1l << i,
200+
Max(10, len2) - 1, (double) histogram[i] * 100 / loop_count,
201+
Max(10, len3), buf);
191202
}
192203
}

0 commit comments

Comments
 (0)