bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: bitset: Avoid newlines at the end of translatable strings
Date: Sun, 25 Feb 2024 15:54:26 +0100	[thread overview]
Message-ID: <4928321.3Lj2Plt8kZ@nimes> (raw)

Except in particular situations (such as --help messages, where each
translatable string ends with a newline), it is not a good idea to
include a newline at the end of a translatable string, because:

  - The decision to add a newline after a certain text is a programmer's
    decision; if the translator removes the newline, the program's
    output will get messed up.

  - It's a recipe for mistakes for the translators.

2024-02-25  Bruno Haible  <bruno@clisp.org>

	bitset: Avoid newlines at the end of translatable strings.
	* lib/bitset/stats.c (bitset_percent_histogram_print,
	bitset_log_histogram_print): Print a newline after msg.
	(bitset_stats_print_1): Don't include a newline in the argument of
	bitset_percent_histogram_print or bitset_log_histogram_print.
	(bitset_stats_print): Move newlines outside of translatable strings.

diff --git a/lib/bitset/stats.c b/lib/bitset/stats.c
index a32b0cfd08..5c40fc9466 100644
--- a/lib/bitset/stats.c
+++ b/lib/bitset/stats.c
@@ -115,7 +115,7 @@ bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
   if (!total)
-  fprintf (file, "%s %s", name, msg);
+  fprintf (file, "%s %s\n", name, msg);
   for (unsigned i = 0; i < n_bins; i++)
     fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
              i * 100.0 / n_bins,
@@ -147,7 +147,7 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
   /* 2 * ceil (log10 (2) * (N - 1)) + 1.  */
   unsigned max_width = 2 * (unsigned) (0.30103 * (n_bins - 1) + 0.9999) + 1;
-  fprintf (file, "%s %s", name, msg);
+  fprintf (file, "%s %s\n", name, msg);
     unsigned i;
     for (i = 0; i < 2; i++)
@@ -195,13 +195,13 @@ bitset_stats_print_1 (FILE *file, const char *name,
   fprintf (file, _("%u bitset_lists\n"), stats->lists);
-  bitset_log_histogram_print (file, name, _("count log histogram\n"),
+  bitset_log_histogram_print (file, name, _("count log histogram"),
                               BITSET_LOG_COUNT_BINS, stats->list_counts);
-  bitset_log_histogram_print (file, name, _("size log histogram\n"),
+  bitset_log_histogram_print (file, name, _("size log histogram"),
                               BITSET_LOG_SIZE_BINS, stats->list_sizes);
-  bitset_percent_histogram_print (file, name, _("density histogram\n"),
+  bitset_percent_histogram_print (file, name, _("density histogram"),
                                   BITSET_DENSITY_BINS, stats->list_density);
@@ -213,10 +213,13 @@ bitset_stats_print (FILE *file, MAYBE_UNUSED bool verbose)
   if (!bitset_stats_info)
-  fprintf (file, _("Bitset statistics:\n\n"));
+  fprintf (file, "%s\n\n", _("Bitset statistics:"));
   if (bitset_stats_info->runs > 1)
-    fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
+    {
+      fprintf (file, _("Accumulated runs = %u"), bitset_stats_info->runs);
+      fputc ('\n', file);
+    }
   for (int i = 0; i < BITSET_TYPE_NUM; i++)
     bitset_stats_print_1 (file, bitset_type_names[i],
@@ -260,7 +263,7 @@ bitset_stats_read (const char *file_name)
           if (ferror (file))
             perror (_("cannot read stats file"));
-            fprintf (stderr, _("bad stats file size\n"));
+            fprintf (stderr, "%s\n", _("bad stats file size"));
       if (fclose (file) != 0)
         perror (_("cannot read stats file"));

                 reply	other threads:[~2024-02-25 14:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4928321.3Lj2Plt8kZ@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).