From: Bruno Haible Date: Fri, 11 Feb 2005 11:10:54 +0000 (+0000) Subject: New functions po_message_remove_filepos, po_message_add_filepos. X-Git-Tag: v0.14.2~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbf9d579c351397fb25d2ca8b58bd22bf4b30b12;p=thirdparty%2Fgettext.git New functions po_message_remove_filepos, po_message_add_filepos. --- diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index faf07735f..b78e1dcdc 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,8 @@ +2005-02-10 Bruno Haible + + * windows/gettextpo.def: Add po_message_remove_filepos, + po_message_add_filepos. + 2005-02-10 Bruno Haible * windows/gettextpo.def: Add po_message_set_extracted_comments. diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index fd92e7a6a..3eaa36247 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2005-02-10 Bruno Haible + + * gettext-po.h (po_message_remove_filepos, po_message_add_filepos): New + declarations. + * gettext-po.c (po_message_remove_filepos, po_message_add_filepos): New + functions. + Suggested by Asgeir Frimannsson . + 2005-02-10 Bruno Haible * gettext-po.h (po_message_set_extracted_comments): New declaration. diff --git a/gettext-tools/src/gettext-po.c b/gettext-tools/src/gettext-po.c index 8a8119782..0508616aa 100644 --- a/gettext-tools/src/gettext-po.c +++ b/gettext-tools/src/gettext-po.c @@ -686,6 +686,46 @@ po_message_filepos (po_message_t message, int i) } +/* Remove the i-th file position from a message. + The indices of all following file positions for the message are decremented + by one. */ + +void +po_message_remove_filepos (po_message_t message, int i) +{ + message_ty *mp = (message_ty *) message; + + if (i >= 0) + { + size_t j = (size_t)i; + size_t n = mp->filepos_count; + + if (j < n) + { + mp->filepos_count = n = n - 1; + free ((char *) mp->filepos[j].file_name); + for (; j < n; j++) + mp->filepos[j] = mp->filepos[j + 1]; + } + } +} + + +/* Add a file position to a message, if it is not already present for the + message. + file is the file name. + start_line is the line number where the string starts, or (size_t)(-1) if no + line number is available. */ + +void +po_message_add_filepos (po_message_t message, const char *file, size_t start_line) +{ + message_ty *mp = (message_ty *) message; + + message_comment_filepos (mp, file, start_line); +} + + /* Return true if the message is marked obsolete. */ int diff --git a/gettext-tools/src/gettext-po.h b/gettext-tools/src/gettext-po.h index 8baec0195..e54d966ac 100644 --- a/gettext-tools/src/gettext-po.h +++ b/gettext-tools/src/gettext-po.h @@ -188,6 +188,18 @@ extern void po_message_set_extracted_comments (po_message_t message, const char range. */ extern po_filepos_t po_message_filepos (po_message_t message, int i); +/* Remove the i-th file position from a message. + The indices of all following file positions for the message are decremented + by one. */ +extern void po_message_remove_filepos (po_message_t message, int i); + +/* Add a file position to a message, if it is not already present for the + message. + file is the file name. + start_line is the line number where the string starts, or (size_t)(-1) if no + line number is available. */ +extern void po_message_add_filepos (po_message_t message, const char *file, size_t start_line); + /* Return true if the message is marked obsolete. */ extern int po_message_is_obsolete (po_message_t message); diff --git a/gettext-tools/windows/gettextpo.def b/gettext-tools/windows/gettextpo.def index f6358c9a3..16d477a3c 100644 --- a/gettext-tools/windows/gettextpo.def +++ b/gettext-tools/windows/gettextpo.def @@ -10,6 +10,7 @@ po_file_write po_filepos_file po_filepos_start_line po_header_field +po_message_add_filepos po_message_check_format po_message_comments po_message_create @@ -25,6 +26,7 @@ po_message_msgid po_message_msgid_plural po_message_msgstr po_message_msgstr_plural +po_message_remove_filepos po_message_set_comments po_message_set_extracted_comments po_message_set_format