From: Bruno Haible Date: Mon, 22 Oct 2007 01:42:25 +0000 (+0000) Subject: Normalize the leading space of every comment line during the input phase X-Git-Tag: v0.17~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1b1b593f018e8334300ce948d87c4fe42a402ea;p=thirdparty%2Fgettext.git Normalize the leading space of every comment line during the input phase rather than during output. --- diff --git a/NEWS b/NEWS index d0b6374c5..cf26637ec 100644 --- 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. diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 837e6e4b5..f870e01d9 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,15 @@ +2007-10-21 Bruno Haible + + 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 . + 2007-10-20 Bruno Haible * msgmerge.c (message_merge): Set the fuzzy flag if the msgid_plural diff --git a/gettext-tools/src/read-catalog-abstract.c b/gettext-tools/src/read-catalog-abstract.c index 56385ee02..e78a031b9 100644 --- a/gettext-tools/src/read-catalog-abstract.c +++ b/gettext-tools/src/read-catalog-abstract.c @@ -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 @@ -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); + } } } diff --git a/gettext-tools/src/write-po.c b/gettext-tools/src/write-po.c index 915af0eea..105d062cd 100644 --- a/gettext-tools/src/write-po.c +++ b/gettext-tools/src/write-po.c @@ -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"); diff --git a/gettext-tools/src/write-stringtable.c b/gettext-tools/src/write-stringtable.c index 2c84927ab..4544c64c7 100644 --- a/gettext-tools/src/write-stringtable.c +++ b/gettext-tools/src/write-stringtable.c @@ -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 , 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: ");