From: Bruno Haible Date: Fri, 11 Feb 2005 11:10:13 +0000 (+0000) Subject: New function po_message_set_extracted_comments. X-Git-Tag: v0.14.2~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0780b0583a9b7e16afe7e3d400e29223edeeefd1;p=thirdparty%2Fgettext.git New function po_message_set_extracted_comments. --- diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index a8a0fd971..faf07735f 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,7 @@ +2005-02-10 Bruno Haible + + * windows/gettextpo.def: Add po_message_set_extracted_comments. + 2005-02-07 Bruno Haible * windows/gettextlib.def: Add c_strcasecmp, c_strncasecmp. diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 911d30bb5..fd92e7a6a 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2005-02-10 Bruno Haible + + * gettext-po.h (po_message_set_extracted_comments): New declaration. + * gettext-po.c (po_message_set_extracted_comments): New function. + Suggested by Asgeir Frimannsson . + 2005-02-08 Bruno Haible * msginit.c (get_user_email): Cast _() to 'char *', to avoid compiler diff --git a/gettext-tools/src/gettext-po.c b/gettext-tools/src/gettext-po.c index fafb3abc8..8a8119782 100644 --- a/gettext-tools/src/gettext-po.c +++ b/gettext-tools/src/gettext-po.c @@ -631,6 +631,46 @@ po_message_extracted_comments (po_message_t message) } +/* Change the extracted comments for a message. + comments should be a multiline string, ending in a newline, or empty. */ + +void +po_message_set_extracted_comments (po_message_t message, const char *comments) +{ + message_ty *mp = (message_ty *) message; + string_list_ty *slp = string_list_alloc (); + + { + char *copy = xstrdup (comments); + char *rest; + + rest = copy; + while (*rest != '\0') + { + char *newline = strchr (rest, '\n'); + + if (newline != NULL) + { + *newline = '\0'; + string_list_append (slp, rest); + rest = newline + 1; + } + else + { + string_list_append (slp, rest); + break; + } + } + free (copy); + } + + if (mp->comment_dot != NULL) + string_list_free (mp->comment_dot); + + mp->comment_dot = slp; +} + + /* Return the i-th file position for a message, or NULL if i is out of range. */ diff --git a/gettext-tools/src/gettext-po.h b/gettext-tools/src/gettext-po.h index a11c1f912..8baec0195 100644 --- a/gettext-tools/src/gettext-po.h +++ b/gettext-tools/src/gettext-po.h @@ -1,5 +1,5 @@ /* Public API for GNU gettext PO files - contained in libgettextpo. - Copyright (C) 2003-2004 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify @@ -180,6 +180,10 @@ extern void po_message_set_comments (po_message_t message, const char *comments) /* Return the extracted comments for a message. */ extern const char * po_message_extracted_comments (po_message_t message); +/* Change the extracted comments for a message. + comments should be a multiline string, ending in a newline, or empty. */ +extern void po_message_set_extracted_comments (po_message_t message, const char *comments); + /* Return the i-th file position for a message, or NULL if i is out of range. */ extern po_filepos_t po_message_filepos (po_message_t message, int i); diff --git a/gettext-tools/windows/gettextpo.def b/gettext-tools/windows/gettextpo.def index c0f307f87..f6358c9a3 100644 --- a/gettext-tools/windows/gettextpo.def +++ b/gettext-tools/windows/gettextpo.def @@ -26,6 +26,7 @@ po_message_msgid_plural po_message_msgstr po_message_msgstr_plural po_message_set_comments +po_message_set_extracted_comments po_message_set_format po_message_set_fuzzy po_message_set_msgid