From: Bruno Haible Date: Wed, 16 Apr 2003 10:11:03 +0000 (+0000) Subject: Slightly better code structure. X-Git-Tag: v0.12~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c0c3cacfced1e95516922db51f9046edb543d29;p=thirdparty%2Fgettext.git Slightly better code structure. --- diff --git a/ChangeLog b/ChangeLog index c6d952add..c379b8e46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-04-13 Bruno Haible + + * read-po.c (readall_directive_message): Separate accumulation and + reset. + * x-po.c (extract_directive_message): Likewise. + 2003-04-12 Bruno Haible * Makefile.vms: Don't use the force target. diff --git a/gettext-tools/src/read-po.c b/gettext-tools/src/read-po.c index 772f87629..17949bc6e 100644 --- a/gettext-tools/src/read-po.c +++ b/gettext-tools/src/read-po.c @@ -186,21 +186,16 @@ readall_directive_message (po_ty *that, mp->obsolete = obsolete; } - /* Add the accumulated comments to the message. Clear the - accumulation in preparation for the next message. */ + /* Add the accumulated comments to the message. */ if (this->comment != NULL) { for (j = 0; j < this->comment->nitems; ++j) message_comment_append (mp, this->comment->item[j]); - string_list_free (this->comment); - this->comment = NULL; } if (this->comment_dot != NULL) { for (j = 0; j < this->comment_dot->nitems; ++j) message_comment_dot_append (mp, this->comment_dot->item[j]); - string_list_free (this->comment_dot); - this->comment_dot = NULL; } for (j = 0; j < this->filepos_count; ++j) { @@ -208,13 +203,30 @@ readall_directive_message (po_ty *that, pp = &this->filepos[j]; message_comment_filepos (mp, pp->file_name, pp->line_number); - free (pp->file_name); } mp->is_fuzzy = this->is_fuzzy; for (i = 0; i < NFORMATS; i++) mp->is_format[i] = this->is_format[i]; mp->do_wrap = this->do_wrap; + /* Prepare for next message. */ + if (this->comment != NULL) + { + string_list_free (this->comment); + this->comment = NULL; + } + if (this->comment_dot != NULL) + { + string_list_free (this->comment_dot); + this->comment_dot = NULL; + } + for (j = 0; j < this->filepos_count; ++j) + { + lex_pos_ty *pp; + + pp = &this->filepos[j]; + free (pp->file_name); + } if (this->filepos != NULL) free (this->filepos); this->filepos_count = 0; diff --git a/gettext-tools/src/x-po.c b/gettext-tools/src/x-po.c index bf7f60e26..1c458487a 100644 --- a/gettext-tools/src/x-po.c +++ b/gettext-tools/src/x-po.c @@ -1,5 +1,5 @@ /* xgettext PO backend. - Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. This file was written by Peter Miller @@ -149,21 +149,16 @@ extract_directive_message (po_ty *that, message_list_append (this->mlp, mp); } - /* Add the accumulated comments to the message. Clear the - accumulation in preparation for the next message. */ + /* Add the accumulated comments to the message. */ if (this->comment != NULL) { for (j = 0; j < this->comment->nitems; ++j) message_comment_append (mp, this->comment->item[j]); - string_list_free (this->comment); - this->comment = NULL; } if (this->comment_dot != NULL) { for (j = 0; j < this->comment_dot->nitems; ++j) message_comment_dot_append (mp, this->comment_dot->item[j]); - string_list_free (this->comment_dot); - this->comment_dot = NULL; } mp->is_fuzzy = this->is_fuzzy; for (i = 0; i < NFORMATS; i++) @@ -175,6 +170,24 @@ extract_directive_message (po_ty *that, pp = &this->filepos[j]; message_comment_filepos (mp, pp->file_name, pp->line_number); + } + + /* Prepare for next message. */ + if (this->comment != NULL) + { + string_list_free (this->comment); + this->comment = NULL; + } + if (this->comment_dot != NULL) + { + string_list_free (this->comment_dot); + this->comment_dot = NULL; + } + for (j = 0; j < this->filepos_count; ++j) + { + lex_pos_ty *pp; + + pp = &this->filepos[j]; free (pp->file_name); } if (this->filepos != NULL)