]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Normalize the leading space of every comment line during the input phase
authorBruno Haible <bruno@clisp.org>
Mon, 22 Oct 2007 01:42:25 +0000 (01:42 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:22 +0000 (12:15 +0200)
rather than during output.

NEWS
gettext-tools/src/ChangeLog
gettext-tools/src/read-catalog-abstract.c
gettext-tools/src/write-po.c
gettext-tools/src/write-stringtable.c

diff --git a/NEWS b/NEWS
index d0b6374c577b37d8ab7733fad0e2bd534b973775..cf26637ec5b3957d489736d7d70bdbe881e67010 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,14 @@ Version 0.16.2 - January 2007
 * libgettextpo library:
   - New functions are available for querying the list of supported format
     types.
+  - The functions po_message_comments and po_message_extracted_comments
+    return a multiline string where each line no longer starts with a redundant
+    space. The leading space in every comment line is now stripped while
+    reading the PO file.
+  - Conversely, when you pass a multiline string to the function
+    po_message_set_comments or po_message_set_extracted_comments, you normally
+    don't pass a space at the beginning of each line, because such spaces are
+    no longer trimmed during output.
 
 * Documentation:
   - The "Users" chapter has been completely rewritten.
index 837e6e4b55c80f8a4f52348f5afb63a9cd1b9ea4..f870e01d9f68717e5759791888d51fd4b46babad 100644 (file)
@@ -1,3 +1,15 @@
+2007-10-21  Bruno Haible  <bruno@clisp.org>
+
+       Normalize the leading space of every comment line during input, not
+       during output.
+       * read-catalog-abstract.c (po_callback_comment_dispatcher): Before
+       calling po_callback_comment or po_callback_comment_dot, drop the
+       leading space.
+       * write-po.c (message_print_comment, message_print_comment_dot): Don't
+       remove the leading space of every comment line.
+       * write-stringtable.c (write_message): Likewise.
+       Suggested by Dwayne Bailey <dwayne@translate.org.za>.
+
 2007-10-20  Bruno Haible  <bruno@clisp.org>
 
        * msgmerge.c (message_merge): Set the fuzzy flag if the msgid_plural
index 56385ee02b2753cffe0d750ac3788b4c1e1de493..e78a031b93d145727554fc04d347a65192bf1316 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading PO files, abstract class.
-   Copyright (C) 1995-1996, 1998, 2000-2006 Free Software Foundation, Inc.
+   Copyright (C) 1995-1996, 1998, 2000-2007 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -649,7 +649,14 @@ void
 po_callback_comment_dispatcher (const char *s)
 {
   if (*s == '.')
-    po_callback_comment_dot (s + 1);
+    {
+      s++;
+      /* There is usually a space before the comment.  People don't
+        consider it part of the comment, therefore remove it here.  */
+      if (*s == ' ')
+       s++;
+      po_callback_comment_dot (s);
+    }
   else if (*s == ':')
     {
       /* Parse the file location string.  The appropriate callback will be
@@ -669,6 +676,12 @@ po_callback_comment_dispatcher (const char *s)
       if (po_parse_comment_solaris_filepos (s))
        /* Do nothing, it is a Sun-style file pos line.  */ ;
       else
-       po_callback_comment (s);
+       {
+         /* There is usually a space before the comment.  People don't
+            consider it part of the comment, therefore remove it here.  */
+         if (*s == ' ')
+           s++;
+         po_callback_comment (s);
+       }
     }
 }
index 915af0eea78598c70614f0d9146791de270ef1d0..105d062cd320c59543dbf1712e8fbd1558196231 100644 (file)
@@ -246,7 +246,7 @@ message_print_comment (const message_ty *mp, ostream_t stream)
            {
              const char *e;
              ostream_write_str (stream, "#");
-             if (*s != '\0' && *s != ' ')
+             if (*s != '\0')
                ostream_write_str (stream, " ");
              e = strchr (s, '\n');
              if (e == NULL)
@@ -284,7 +284,7 @@ message_print_comment_dot (const message_ty *mp, ostream_t stream)
        {
          const char *s = mp->comment_dot->item[j];
          ostream_write_str (stream, "#.");
-         if (*s != '\0' && *s != ' ')
+         if (*s != '\0')
            ostream_write_str (stream, " ");
          ostream_write_str (stream, s);
          ostream_write_str (stream, "\n");
index 2c84927ab302ec63c272d89e23062f289b110836..4544c64c739b4a07276a7f5d1bb2b1e52cae6d42 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing NeXTstep/GNUstep .strings files.
-   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -110,7 +110,7 @@ write_message (ostream_t stream, const message_ty *mp,
          if (c_strstr (s, "*/") == NULL)
            {
              ostream_write_str (stream, "/*");
-             if (*s != '\0' && *s != '\n' && *s != ' ')
+             if (*s != '\0' && *s != '\n')
                ostream_write_str (stream, " ");
              ostream_write_str (stream, s);
              ostream_write_str (stream, " */\n");
@@ -120,7 +120,7 @@ write_message (ostream_t stream, const message_ty *mp,
              {
                const char *e;
                ostream_write_str (stream, "//");
-               if (*s != '\0' && *s != '\n' && *s != ' ')
+               if (*s != '\0' && *s != '\n')
                  ostream_write_str (stream, " ");
                e = strchr (s, '\n');
                if (e == NULL)
@@ -163,7 +163,7 @@ write_message (ostream_t stream, const message_ty *mp,
                {
                  const char *e;
                  ostream_write_str (stream, "//");
-                 if (first || (*s != '\0' && *s != '\n' && *s != ' '))
+                 if (first || (*s != '\0' && *s != '\n'))
                    ostream_write_str (stream, " ");
                  if (first)
                    ostream_write_str (stream, "Comment: ");