From: Bruno Haible Date: Sun, 28 Jul 2024 12:29:22 +0000 (+0200) Subject: Refactor. X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=10dc3dfd9cef51350a2c6f829126cd279bf33fc5;p=thirdparty%2Fgettext.git Refactor. Rename the parameter of type 'abstract_catalog_reader_ty *' to catr. Rename the parameter of type 'default_catalog_reader_ty *' to dcatr. Rename the parameter of type 'msgfmt_catalog_reader_ty *' to mcatr. * gettext-tools/src/read-catalog-abstract.h (abstract_catalog_reader_class_ty): Change first parameter name of all methods. (struct catalog_input_format): Likewise. (catalog_reader_parse, catalog_reader_free): Change first parameter name. * gettext-tools/src/read-catalog-abstract.c (catalog_reader_alloc): Rename local variable 'pop'. (catalog_reader_free, call_parse_brief, call_parse_debrief, call_directive_domain, call_directive_message, call_comment, call_comment_dot, call_comment_filepos, call_comment_special, parse_start, parse_end, catalog_reader_parse): Change first parameter name. * gettext-tools/src/read-catalog.h (default_constructor, default_destructor, default_parse_brief, default_parse_debrief, default_directive_domain, default_directive_message, default_comment, default_comment_dot, default_comment_filepos, default_comment_special, default_set_domain, default_add_message): Change first parameter name. * gettext-tools/src/read-catalog.c (call_set_domain, call_add_message, call_frob_new_message, default_constructor, default_destructor, default_parse_brief, default_parse_debrief, default_copy_comment_state, default_reset_comment_state, default_directive_domain, default_directive_message, default_comment, default_comment_dot, default_comment_filepos, default_comment_special, default_set_domain, default_add_message): Change first parameter name. * gettext-tools/src/msgfmt.c (msgfmt_constructor, msgfmt_parse_debrief, msgfmt_set_domain, msgfmt_add_message, msgfmt_frob_new_message, msgfmt_comment_special): Change first parameter name. (read_catalog_file_msgfmt): Rename local variable 'pop'. * gettext-tools/src/x-po.c (extract): Rename local variable 'pop'. * gettext-tools/src/xgettext.c (exclude_directive_domain, exclude_directive_message): Change first parameter name. * gettext-tools/src/read-po.c (po_parse): Change first parameter name. * gettext-tools/src/read-properties.c (properties_parse): Likewise. * gettext-tools/src/read-stringtable.c (stringtable_parse): Likewise. --- diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index 1ec51ac37..5aebec28a 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -1163,33 +1163,33 @@ struct msgfmt_catalog_reader_ty /* Prepare for first message. */ static void -msgfmt_constructor (abstract_catalog_reader_ty *that) +msgfmt_constructor (abstract_catalog_reader_ty *catr) { - msgfmt_catalog_reader_ty *this = (msgfmt_catalog_reader_ty *) that; + msgfmt_catalog_reader_ty *mcatr = (msgfmt_catalog_reader_ty *) catr; /* Invoke superclass constructor. */ - default_constructor (that); + default_constructor (catr); - this->has_header_entry = false; + mcatr->has_header_entry = false; } /* Some checks after whole file is read. */ static void -msgfmt_parse_debrief (abstract_catalog_reader_ty *that) +msgfmt_parse_debrief (abstract_catalog_reader_ty *catr) { - msgfmt_catalog_reader_ty *this = (msgfmt_catalog_reader_ty *) that; + msgfmt_catalog_reader_ty *mcatr = (msgfmt_catalog_reader_ty *) catr; /* Invoke superclass method. */ - default_parse_debrief (that); + default_parse_debrief (catr); /* Test whether header entry was found. */ if (check_header) { - if (!this->has_header_entry) + if (!mcatr->has_header_entry) { size_t prefix_width = - multiline_error (xasprintf ("%s: ", this->file_name), + multiline_error (xasprintf ("%s: ", mcatr->file_name), xasprintf (_("warning: PO file header missing or invalid\n"))); multiline_append (prefix_width, xasprintf (_("warning: charset conversion will not work\n"))); @@ -1200,7 +1200,7 @@ msgfmt_parse_debrief (abstract_catalog_reader_ty *that) /* Set 'domain' directive when seen in .po file. */ static void -msgfmt_set_domain (default_catalog_reader_ty *this, char *name) +msgfmt_set_domain (default_catalog_reader_ty *dcatr, char *name) { /* If no output file was given, we change it with each 'domain' directive. */ @@ -1228,8 +1228,8 @@ msgfmt_set_domain (default_catalog_reader_ty *this, char *name) /* Set new domain. */ current_domain = new_domain (name, add_mo_suffix (name)); - this->domain = current_domain->domain_name; - this->mlp = current_domain->mlp; + dcatr->domain = current_domain->domain_name; + dcatr->mlp = current_domain->mlp; } else { @@ -1244,7 +1244,7 @@ msgfmt_set_domain (default_catalog_reader_ty *this, char *name) static void -msgfmt_add_message (default_catalog_reader_ty *this, +msgfmt_add_message (default_catalog_reader_ty *dcatr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, @@ -1262,13 +1262,13 @@ msgfmt_add_message (default_catalog_reader_ty *this, { current_domain = new_domain (MESSAGE_DOMAIN_DEFAULT, add_mo_suffix (MESSAGE_DOMAIN_DEFAULT)); - /* Keep current_domain and this->domain synchronized. */ - this->domain = current_domain->domain_name; - this->mlp = current_domain->mlp; + /* Keep current_domain and dcatr->domain synchronized. */ + dcatr->domain = current_domain->domain_name; + dcatr->mlp = current_domain->mlp; } /* Invoke superclass method. */ - default_add_message (this, msgctxt, msgid, msgid_pos, msgid_plural, + default_add_message (dcatr, msgctxt, msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, prev_msgctxt, prev_msgid, prev_msgid_plural, force_fuzzy, obsolete); @@ -1276,11 +1276,11 @@ msgfmt_add_message (default_catalog_reader_ty *this, static void -msgfmt_frob_new_message (default_catalog_reader_ty *that, message_ty *mp, +msgfmt_frob_new_message (default_catalog_reader_ty *dcatr, message_ty *mp, const lex_pos_ty *msgid_pos, const lex_pos_ty *msgstr_pos) { - msgfmt_catalog_reader_ty *this = (msgfmt_catalog_reader_ty *) that; + msgfmt_catalog_reader_ty *mcatr = (msgfmt_catalog_reader_ty *) dcatr; if (!mp->obsolete) { @@ -1313,7 +1313,7 @@ msgfmt_frob_new_message (default_catalog_reader_ty *that, message_ty *mp, /* Test for header entry. */ if (is_header (mp)) { - this->has_header_entry = true; + mcatr->has_header_entry = true; } else /* We don't count the header entry in the statistic so place @@ -1329,14 +1329,14 @@ msgfmt_frob_new_message (default_catalog_reader_ty *that, message_ty *mp, /* Test for '#, fuzzy' comments and warn. */ static void -msgfmt_comment_special (abstract_catalog_reader_ty *that, const char *s) +msgfmt_comment_special (abstract_catalog_reader_ty *catr, const char *s) { - msgfmt_catalog_reader_ty *this = (msgfmt_catalog_reader_ty *) that; + msgfmt_catalog_reader_ty *mcatr = (msgfmt_catalog_reader_ty *) catr; /* Invoke superclass method. */ - default_comment_special (that, s); + default_comment_special (catr, s); - if (this->is_fuzzy) + if (mcatr->is_fuzzy) { static bool warned = false; @@ -1384,26 +1384,26 @@ read_catalog_file_msgfmt (char *filename, catalog_input_format_ty input_syntax) { char *real_filename; FILE *fp = open_catalog_file (filename, &real_filename, true); - default_catalog_reader_ty *pop; - - pop = default_catalog_reader_alloc (&msgfmt_methods); - pop->handle_comments = false; - pop->allow_domain_directives = true; - pop->allow_duplicates = false; - pop->allow_duplicates_if_same_msgstr = false; - pop->file_name = real_filename; - pop->mdlp = NULL; - pop->mlp = NULL; + default_catalog_reader_ty *dcatr; + + dcatr = default_catalog_reader_alloc (&msgfmt_methods); + dcatr->handle_comments = false; + dcatr->allow_domain_directives = true; + dcatr->allow_duplicates = false; + dcatr->allow_duplicates_if_same_msgstr = false; + dcatr->file_name = real_filename; + dcatr->mdlp = NULL; + dcatr->mlp = NULL; if (current_domain != NULL) { - /* Keep current_domain and this->domain synchronized. */ - pop->domain = current_domain->domain_name; - pop->mlp = current_domain->mlp; + /* Keep current_domain and dcatr->domain synchronized. */ + dcatr->domain = current_domain->domain_name; + dcatr->mlp = current_domain->mlp; } po_lex_pass_obsolete_entries (true); - catalog_reader_parse ((abstract_catalog_reader_ty *) pop, fp, real_filename, + catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename, filename, false, input_syntax); - catalog_reader_free ((abstract_catalog_reader_ty *) pop); + catalog_reader_free ((abstract_catalog_reader_ty *) dcatr); if (fp != stdin) fclose (fp); diff --git a/gettext-tools/src/read-catalog-abstract.c b/gettext-tools/src/read-catalog-abstract.c index f1ed9f408..036d56870 100644 --- a/gettext-tools/src/read-catalog-abstract.c +++ b/gettext-tools/src/read-catalog-abstract.c @@ -47,22 +47,22 @@ static abstract_catalog_reader_ty *callback_arg; abstract_catalog_reader_ty * catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table) { - abstract_catalog_reader_ty *pop; + abstract_catalog_reader_ty *catr; - pop = (abstract_catalog_reader_ty *) xmalloc (method_table->size); - pop->methods = method_table; + catr = (abstract_catalog_reader_ty *) xmalloc (method_table->size); + catr->methods = method_table; if (method_table->constructor) - method_table->constructor (pop); - return pop; + method_table->constructor (catr); + return catr; } void -catalog_reader_free (abstract_catalog_reader_ty *pop) +catalog_reader_free (abstract_catalog_reader_ty *catr) { - if (pop->methods->destructor) - pop->methods->destructor (pop); - free (pop); + if (catr->methods->destructor) + catr->methods->destructor (catr); + free (catr); } @@ -71,28 +71,28 @@ catalog_reader_free (abstract_catalog_reader_ty *pop) static inline void -call_parse_brief (abstract_catalog_reader_ty *pop) +call_parse_brief (abstract_catalog_reader_ty *catr) { - if (pop->methods->parse_brief) - pop->methods->parse_brief (pop); + if (catr->methods->parse_brief) + catr->methods->parse_brief (catr); } static inline void -call_parse_debrief (abstract_catalog_reader_ty *pop) +call_parse_debrief (abstract_catalog_reader_ty *catr) { - if (pop->methods->parse_debrief) - pop->methods->parse_debrief (pop); + if (catr->methods->parse_debrief) + catr->methods->parse_debrief (catr); } static inline void -call_directive_domain (abstract_catalog_reader_ty *pop, char *name) +call_directive_domain (abstract_catalog_reader_ty *catr, char *name) { - if (pop->methods->directive_domain) - pop->methods->directive_domain (pop, name); + if (catr->methods->directive_domain) + catr->methods->directive_domain (catr, name); } static inline void -call_directive_message (abstract_catalog_reader_ty *pop, +call_directive_message (abstract_catalog_reader_ty *catr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, @@ -104,43 +104,43 @@ call_directive_message (abstract_catalog_reader_ty *pop, char *prev_msgid_plural, bool force_fuzzy, bool obsolete) { - if (pop->methods->directive_message) - pop->methods->directive_message (pop, msgctxt, - msgid, msgid_pos, msgid_plural, - msgstr, msgstr_len, msgstr_pos, - prev_msgctxt, - prev_msgid, - prev_msgid_plural, - force_fuzzy, obsolete); + if (catr->methods->directive_message) + catr->methods->directive_message (catr, msgctxt, + msgid, msgid_pos, msgid_plural, + msgstr, msgstr_len, msgstr_pos, + prev_msgctxt, + prev_msgid, + prev_msgid_plural, + force_fuzzy, obsolete); } static inline void -call_comment (abstract_catalog_reader_ty *pop, const char *s) +call_comment (abstract_catalog_reader_ty *catr, const char *s) { - if (pop->methods->comment != NULL) - pop->methods->comment (pop, s); + if (catr->methods->comment != NULL) + catr->methods->comment (catr, s); } static inline void -call_comment_dot (abstract_catalog_reader_ty *pop, const char *s) +call_comment_dot (abstract_catalog_reader_ty *catr, const char *s) { - if (pop->methods->comment_dot != NULL) - pop->methods->comment_dot (pop, s); + if (catr->methods->comment_dot != NULL) + catr->methods->comment_dot (catr, s); } static inline void -call_comment_filepos (abstract_catalog_reader_ty *pop, +call_comment_filepos (abstract_catalog_reader_ty *catr, const char *file_name, size_t line_number) { - if (pop->methods->comment_filepos) - pop->methods->comment_filepos (pop, file_name, line_number); + if (catr->methods->comment_filepos) + catr->methods->comment_filepos (catr, file_name, line_number); } static inline void -call_comment_special (abstract_catalog_reader_ty *pop, const char *s) +call_comment_special (abstract_catalog_reader_ty *catr, const char *s) { - if (pop->methods->comment_special != NULL) - pop->methods->comment_special (pop, s); + if (catr->methods->comment_special != NULL) + catr->methods->comment_special (catr, s); } @@ -149,27 +149,27 @@ call_comment_special (abstract_catalog_reader_ty *pop, const char *s) static inline void -parse_start (abstract_catalog_reader_ty *pop) +parse_start (abstract_catalog_reader_ty *catr) { /* The parse will call the po_callback_... functions (see below) when the various directive are recognised. The callback_arg variable is used to tell these functions which instance is to have the relevant method invoked. */ - callback_arg = pop; + callback_arg = catr; - call_parse_brief (pop); + call_parse_brief (catr); } static inline void -parse_end (abstract_catalog_reader_ty *pop) +parse_end (abstract_catalog_reader_ty *catr) { - call_parse_debrief (pop); + call_parse_debrief (catr); callback_arg = NULL; } void -catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp, +catalog_reader_parse (abstract_catalog_reader_ty *catr, FILE *fp, const char *real_filename, const char *logical_filename, bool is_pot_role, catalog_input_format_ty input_syntax) @@ -177,9 +177,9 @@ catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp, error_message_count = 0; /* Parse the stream's content. */ - parse_start (pop); - input_syntax->parse (pop, fp, real_filename, logical_filename, is_pot_role); - parse_end (pop); + parse_start (catr); + input_syntax->parse (catr, fp, real_filename, logical_filename, is_pot_role); + parse_end (catr); if (error_message_count > 0) po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, diff --git a/gettext-tools/src/read-catalog-abstract.h b/gettext-tools/src/read-catalog-abstract.h index 951c16979..1cc09572d 100644 --- a/gettext-tools/src/read-catalog-abstract.h +++ b/gettext-tools/src/read-catalog-abstract.h @@ -60,26 +60,26 @@ struct abstract_catalog_reader_class_ty size_t size; /* What to do immediately after the instance is malloc()ed. */ - void (*constructor) (struct abstract_catalog_reader_ty *pop); + void (*constructor) (struct abstract_catalog_reader_ty *catr); /* What to do immediately before the instance is free()ed. */ - void (*destructor) (struct abstract_catalog_reader_ty *pop); + void (*destructor) (struct abstract_catalog_reader_ty *catr); /* This method is invoked before the parse, but after the file is opened by the lexer. */ - void (*parse_brief) (struct abstract_catalog_reader_ty *pop); + void (*parse_brief) (struct abstract_catalog_reader_ty *catr); /* This method is invoked after the parse, but before the file is closed by the lexer. The intention is to make consistency checks against the file here, and emit the errors through the lex_error* functions. */ - void (*parse_debrief) (struct abstract_catalog_reader_ty *pop); + void (*parse_debrief) (struct abstract_catalog_reader_ty *catr); /* What to do with a domain directive. */ - void (*directive_domain) (struct abstract_catalog_reader_ty *pop, char *name); + void (*directive_domain) (struct abstract_catalog_reader_ty *catr, char *name); /* What to do with a message directive. */ - void (*directive_message) (struct abstract_catalog_reader_ty *pop, + void (*directive_message) (struct abstract_catalog_reader_ty *catr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, char *msgid_plural, @@ -92,25 +92,25 @@ struct abstract_catalog_reader_class_ty /* What to do with a plain-vanilla comment. The expectation is that they will be accumulated, and added to the next message definition seen. Or completely ignored. */ - void (*comment) (struct abstract_catalog_reader_ty *pop, const char *s); + void (*comment) (struct abstract_catalog_reader_ty *catr, const char *s); /* What to do with a comment that starts with a dot (i.e. extracted by xgettext). The expectation is that they will be accumulated, and added to the next message definition seen. Or completely ignored. */ - void (*comment_dot) (struct abstract_catalog_reader_ty *pop, const char *s); + void (*comment_dot) (struct abstract_catalog_reader_ty *catr, const char *s); /* What to do with a file position seen in a comment (i.e. a message location comment extracted by xgettext). The expectation is that they will be accumulated, and added to the next message definition seen. Or completely ignored. */ - void (*comment_filepos) (struct abstract_catalog_reader_ty *pop, + void (*comment_filepos) (struct abstract_catalog_reader_ty *catr, const char *file_name, size_t line_number); /* What to do with a comment that starts with a ',' or '!'; this is a special comment. One of the possible uses is to indicate a inexact translation. */ - void (*comment_special) (struct abstract_catalog_reader_ty *pop, + void (*comment_special) (struct abstract_catalog_reader_ty *catr, const char *s); }; @@ -137,7 +137,7 @@ struct abstract_catalog_reader_ty struct catalog_input_format { /* Parses the contents of FP, invoking the appropriate callbacks. */ - void (*parse) (abstract_catalog_reader_ty *pop, FILE *fp, + void (*parse) (abstract_catalog_reader_ty *catr, FILE *fp, const char *real_filename, const char *logical_filename, bool is_pot_role); @@ -157,7 +157,7 @@ extern abstract_catalog_reader_ty * /* Read a PO file from a stream, and dispatch to the various abstract_catalog_reader_class_ty methods. */ extern void - catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp, + catalog_reader_parse (abstract_catalog_reader_ty *catr, FILE *fp, const char *real_filename, const char *logical_filename, bool is_pot_role, @@ -166,7 +166,7 @@ extern void /* Call the destructor and deallocate a abstract_catalog_reader_ty (or derived class) instance. */ extern void - catalog_reader_free (abstract_catalog_reader_ty *pop); + catalog_reader_free (abstract_catalog_reader_ty *catr); /* Callbacks used by po-gram.y or po-lex.c, indirectly from diff --git a/gettext-tools/src/read-catalog.c b/gettext-tools/src/read-catalog.c index ef533fa81..4f291606b 100644 --- a/gettext-tools/src/read-catalog.c +++ b/gettext-tools/src/read-catalog.c @@ -38,17 +38,17 @@ /* Inline functions to invoke the methods. */ static inline void -call_set_domain (struct default_catalog_reader_ty *this, char *name) +call_set_domain (struct default_catalog_reader_ty *dcatr, char *name) { default_catalog_reader_class_ty *methods = - (default_catalog_reader_class_ty *) this->methods; + (default_catalog_reader_class_ty *) dcatr->methods; if (methods->set_domain) - methods->set_domain (this, name); + methods->set_domain (dcatr, name); } static inline void -call_add_message (struct default_catalog_reader_ty *this, +call_add_message (struct default_catalog_reader_ty *dcatr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, @@ -56,10 +56,10 @@ call_add_message (struct default_catalog_reader_ty *this, bool force_fuzzy, bool obsolete) { default_catalog_reader_class_ty *methods = - (default_catalog_reader_class_ty *) this->methods; + (default_catalog_reader_class_ty *) dcatr->methods; if (methods->add_message) - methods->add_message (this, msgctxt, + methods->add_message (dcatr, msgctxt, msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, prev_msgctxt, prev_msgid, prev_msgid_plural, @@ -67,15 +67,15 @@ call_add_message (struct default_catalog_reader_ty *this, } static inline void -call_frob_new_message (struct default_catalog_reader_ty *this, message_ty *mp, +call_frob_new_message (struct default_catalog_reader_ty *dcatr, message_ty *mp, const lex_pos_ty *msgid_pos, const lex_pos_ty *msgstr_pos) { default_catalog_reader_class_ty *methods = - (default_catalog_reader_class_ty *) this->methods; + (default_catalog_reader_class_ty *) dcatr->methods; if (methods->frob_new_message) - methods->frob_new_message (this, mp, msgid_pos, msgstr_pos); + methods->frob_new_message (dcatr, mp, msgid_pos, msgstr_pos); } @@ -88,149 +88,149 @@ call_frob_new_message (struct default_catalog_reader_ty *this, message_ty *mp, /* Prepare for first message. */ void -default_constructor (abstract_catalog_reader_ty *that) +default_constructor (abstract_catalog_reader_ty *catr) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; size_t i; - this->domain = MESSAGE_DOMAIN_DEFAULT; - this->comment = NULL; - this->comment_dot = NULL; - this->filepos_count = 0; - this->filepos = NULL; - this->is_fuzzy = false; + dcatr->domain = MESSAGE_DOMAIN_DEFAULT; + dcatr->comment = NULL; + dcatr->comment_dot = NULL; + dcatr->filepos_count = 0; + dcatr->filepos = NULL; + dcatr->is_fuzzy = false; for (i = 0; i < NFORMATS; i++) - this->is_format[i] = undecided; - this->range.min = -1; - this->range.max = -1; - this->do_wrap = undecided; + dcatr->is_format[i] = undecided; + dcatr->range.min = -1; + dcatr->range.max = -1; + dcatr->do_wrap = undecided; for (i = 0; i < NSYNTAXCHECKS; i++) - this->do_syntax_check[i] = undecided; + dcatr->do_syntax_check[i] = undecided; } void -default_destructor (abstract_catalog_reader_ty *that) +default_destructor (abstract_catalog_reader_ty *catr) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; size_t j; - /* Do not free this->mdlp and this->mlp. */ - if (this->handle_comments) + /* Do not free dcatr->mdlp and dcatr->mlp. */ + if (dcatr->handle_comments) { - if (this->comment != NULL) - string_list_free (this->comment); - if (this->comment_dot != NULL) - string_list_free (this->comment_dot); + if (dcatr->comment != NULL) + string_list_free (dcatr->comment); + if (dcatr->comment_dot != NULL) + string_list_free (dcatr->comment_dot); } - for (j = 0; j < this->filepos_count; ++j) - free ((char *) this->filepos[j].file_name); - if (this->filepos != NULL) - free (this->filepos); + for (j = 0; j < dcatr->filepos_count; ++j) + free ((char *) dcatr->filepos[j].file_name); + if (dcatr->filepos != NULL) + free (dcatr->filepos); } void -default_parse_brief (abstract_catalog_reader_ty *that) +default_parse_brief (abstract_catalog_reader_ty *catr) { - /* We need to parse comments, because even if this->handle_comments + /* We need to parse comments, because even if dcatr->handle_comments is false, we need to know which messages are fuzzy. */ po_lex_pass_comments (true); } void -default_parse_debrief (abstract_catalog_reader_ty *that) +default_parse_debrief (abstract_catalog_reader_ty *catr) { } /* Add the accumulated comments to the message. */ static void -default_copy_comment_state (default_catalog_reader_ty *this, message_ty *mp) +default_copy_comment_state (default_catalog_reader_ty *dcatr, message_ty *mp) { size_t j, i; - if (this->handle_comments) + if (dcatr->handle_comments) { - if (this->comment != NULL) - for (j = 0; j < this->comment->nitems; ++j) - message_comment_append (mp, this->comment->item[j]); - if (this->comment_dot != NULL) - for (j = 0; j < this->comment_dot->nitems; ++j) - message_comment_dot_append (mp, this->comment_dot->item[j]); + if (dcatr->comment != NULL) + for (j = 0; j < dcatr->comment->nitems; ++j) + message_comment_append (mp, dcatr->comment->item[j]); + if (dcatr->comment_dot != NULL) + for (j = 0; j < dcatr->comment_dot->nitems; ++j) + message_comment_dot_append (mp, dcatr->comment_dot->item[j]); } - for (j = 0; j < this->filepos_count; ++j) + for (j = 0; j < dcatr->filepos_count; ++j) { lex_pos_ty *pp; - pp = &this->filepos[j]; + pp = &dcatr->filepos[j]; message_comment_filepos (mp, pp->file_name, pp->line_number); } - mp->is_fuzzy = this->is_fuzzy; + mp->is_fuzzy = dcatr->is_fuzzy; for (i = 0; i < NFORMATS; i++) - mp->is_format[i] = this->is_format[i]; - mp->range = this->range; - mp->do_wrap = this->do_wrap; + mp->is_format[i] = dcatr->is_format[i]; + mp->range = dcatr->range; + mp->do_wrap = dcatr->do_wrap; for (i = 0; i < NSYNTAXCHECKS; i++) - mp->do_syntax_check[i] = this->do_syntax_check[i]; + mp->do_syntax_check[i] = dcatr->do_syntax_check[i]; } static void -default_reset_comment_state (default_catalog_reader_ty *this) +default_reset_comment_state (default_catalog_reader_ty *dcatr) { size_t j, i; - if (this->handle_comments) + if (dcatr->handle_comments) { - if (this->comment != NULL) + if (dcatr->comment != NULL) { - string_list_free (this->comment); - this->comment = NULL; + string_list_free (dcatr->comment); + dcatr->comment = NULL; } - if (this->comment_dot != NULL) + if (dcatr->comment_dot != NULL) { - string_list_free (this->comment_dot); - this->comment_dot = NULL; + string_list_free (dcatr->comment_dot); + dcatr->comment_dot = NULL; } } - for (j = 0; j < this->filepos_count; ++j) - free ((char *) this->filepos[j].file_name); - if (this->filepos != NULL) - free (this->filepos); - this->filepos_count = 0; - this->filepos = NULL; - this->is_fuzzy = false; + for (j = 0; j < dcatr->filepos_count; ++j) + free ((char *) dcatr->filepos[j].file_name); + if (dcatr->filepos != NULL) + free (dcatr->filepos); + dcatr->filepos_count = 0; + dcatr->filepos = NULL; + dcatr->is_fuzzy = false; for (i = 0; i < NFORMATS; i++) - this->is_format[i] = undecided; - this->range.min = -1; - this->range.max = -1; - this->do_wrap = undecided; + dcatr->is_format[i] = undecided; + dcatr->range.min = -1; + dcatr->range.max = -1; + dcatr->do_wrap = undecided; for (i = 0; i < NSYNTAXCHECKS; i++) - this->do_syntax_check[i] = undecided; + dcatr->do_syntax_check[i] = undecided; } /* Process 'domain' directive from .po file. */ void -default_directive_domain (abstract_catalog_reader_ty *that, char *name) +default_directive_domain (abstract_catalog_reader_ty *catr, char *name) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; - call_set_domain (this, name); + call_set_domain (dcatr, name); /* If there are accumulated comments, throw them away, they are probably part of the file header, or about the domain directive, and will be unrelated to the next message. */ - default_reset_comment_state (this); + default_reset_comment_state (dcatr); } /* Process ['msgctxt'/]'msgid'/'msgstr' pair from .po file. */ void -default_directive_message (abstract_catalog_reader_ty *that, +default_directive_message (abstract_catalog_reader_ty *catr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, @@ -241,57 +241,57 @@ default_directive_message (abstract_catalog_reader_ty *that, char *prev_msgid, char *prev_msgid_plural, bool force_fuzzy, bool obsolete) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; - call_add_message (this, msgctxt, msgid, msgid_pos, msgid_plural, + call_add_message (dcatr, msgctxt, msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, prev_msgctxt, prev_msgid, prev_msgid_plural, force_fuzzy, obsolete); /* Prepare for next message. */ - default_reset_comment_state (this); + default_reset_comment_state (dcatr); } void -default_comment (abstract_catalog_reader_ty *that, const char *s) +default_comment (abstract_catalog_reader_ty *catr, const char *s) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; - if (this->handle_comments) + if (dcatr->handle_comments) { - if (this->comment == NULL) - this->comment = string_list_alloc (); - string_list_append (this->comment, s); + if (dcatr->comment == NULL) + dcatr->comment = string_list_alloc (); + string_list_append (dcatr->comment, s); } } void -default_comment_dot (abstract_catalog_reader_ty *that, const char *s) +default_comment_dot (abstract_catalog_reader_ty *catr, const char *s) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; - if (this->handle_comments) + if (dcatr->handle_comments) { - if (this->comment_dot == NULL) - this->comment_dot = string_list_alloc (); - string_list_append (this->comment_dot, s); + if (dcatr->comment_dot == NULL) + dcatr->comment_dot = string_list_alloc (); + string_list_append (dcatr->comment_dot, s); } } void -default_comment_filepos (abstract_catalog_reader_ty *that, +default_comment_filepos (abstract_catalog_reader_ty *catr, const char *file_name, size_t line_number) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; size_t nbytes; lex_pos_ty *pp; - nbytes = (this->filepos_count + 1) * sizeof (this->filepos[0]); - this->filepos = xrealloc (this->filepos, nbytes); - pp = &this->filepos[this->filepos_count++]; + nbytes = (dcatr->filepos_count + 1) * sizeof (dcatr->filepos[0]); + dcatr->filepos = xrealloc (dcatr->filepos, nbytes); + pp = &dcatr->filepos[dcatr->filepos_count++]; pp->file_name = xstrdup (file_name); pp->line_number = line_number; } @@ -299,12 +299,12 @@ default_comment_filepos (abstract_catalog_reader_ty *that, /* Test for '#, fuzzy' comments and warn. */ void -default_comment_special (abstract_catalog_reader_ty *that, const char *s) +default_comment_special (abstract_catalog_reader_ty *catr, const char *s) { - default_catalog_reader_ty *this = (default_catalog_reader_ty *) that; + default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr; - po_parse_comment_special (s, &this->is_fuzzy, this->is_format, &this->range, - &this->do_wrap, this->do_syntax_check); + po_parse_comment_special (s, &dcatr->is_fuzzy, dcatr->is_format, &dcatr->range, + &dcatr->do_wrap, dcatr->do_syntax_check); } @@ -312,11 +312,11 @@ default_comment_special (abstract_catalog_reader_ty *that, const char *s) void -default_set_domain (default_catalog_reader_ty *this, char *name) +default_set_domain (default_catalog_reader_ty *dcatr, char *name) { - if (this->allow_domain_directives) + if (dcatr->allow_domain_directives) /* Override current domain name. Don't free memory. */ - this->domain = name; + dcatr->domain = name; else { po_gram_error_at_line (&gram_pos, @@ -328,7 +328,7 @@ default_set_domain (default_catalog_reader_ty *this, char *name) } void -default_add_message (default_catalog_reader_ty *this, +default_add_message (default_catalog_reader_ty *dcatr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, @@ -342,20 +342,20 @@ default_add_message (default_catalog_reader_ty *this, { message_ty *mp; - if (this->mdlp != NULL) - /* Select the appropriate sublist of this->mdlp. */ - this->mlp = msgdomain_list_sublist (this->mdlp, this->domain, true); + if (dcatr->mdlp != NULL) + /* Select the appropriate sublist of dcatr->mdlp. */ + dcatr->mlp = msgdomain_list_sublist (dcatr->mdlp, dcatr->domain, true); - if (this->allow_duplicates && msgid[0] != '\0') + if (dcatr->allow_duplicates && msgid[0] != '\0') /* Doesn't matter if this message ID has been seen before. */ mp = NULL; else /* See if this message ID has been seen before. */ - mp = message_list_search (this->mlp, msgctxt, msgid); + mp = message_list_search (dcatr->mlp, msgctxt, msgid); if (mp) { - if (!(this->allow_duplicates_if_same_msgstr + if (!(dcatr->allow_duplicates_if_same_msgstr && msgstr_len == mp->msgstr_len && memcmp (msgstr, mp->msgstr, msgstr_len) == 0)) { @@ -385,7 +385,7 @@ default_add_message (default_catalog_reader_ty *this, free (prev_msgid_plural); /* Add the accumulated comments to the message. */ - default_copy_comment_state (this, mp); + default_copy_comment_state (dcatr, mp); } else { @@ -401,13 +401,13 @@ default_add_message (default_catalog_reader_ty *this, mp->prev_msgid = prev_msgid; mp->prev_msgid_plural = prev_msgid_plural; mp->obsolete = obsolete; - default_copy_comment_state (this, mp); + default_copy_comment_state (dcatr, mp); if (force_fuzzy) mp->is_fuzzy = true; - call_frob_new_message (this, mp, msgid_pos, msgstr_pos); + call_frob_new_message (dcatr, mp, msgid_pos, msgstr_pos); - message_list_append (this->mlp, mp); + message_list_append (dcatr->mlp, mp); } } diff --git a/gettext-tools/src/read-catalog.h b/gettext-tools/src/read-catalog.h index 4b0dbd2c6..7fa444ef0 100644 --- a/gettext-tools/src/read-catalog.h +++ b/gettext-tools/src/read-catalog.h @@ -127,13 +127,13 @@ struct default_catalog_reader_ty DEFAULT_CATALOG_READER_TY }; -extern void default_constructor (abstract_catalog_reader_ty *that); -extern void default_destructor (abstract_catalog_reader_ty *that); -extern void default_parse_brief (abstract_catalog_reader_ty *that); -extern void default_parse_debrief (abstract_catalog_reader_ty *that); -extern void default_directive_domain (abstract_catalog_reader_ty *that, +extern void default_constructor (abstract_catalog_reader_ty *catr); +extern void default_destructor (abstract_catalog_reader_ty *catr); +extern void default_parse_brief (abstract_catalog_reader_ty *catr); +extern void default_parse_debrief (abstract_catalog_reader_ty *catr); +extern void default_directive_domain (abstract_catalog_reader_ty *catr, char *name); -extern void default_directive_message (abstract_catalog_reader_ty *that, +extern void default_directive_message (abstract_catalog_reader_ty *catr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, @@ -144,15 +144,15 @@ extern void default_directive_message (abstract_catalog_reader_ty *that, char *prev_msgid, char *prev_msgid_plural, bool force_fuzzy, bool obsolete); -extern void default_comment (abstract_catalog_reader_ty *that, const char *s); -extern void default_comment_dot (abstract_catalog_reader_ty *that, +extern void default_comment (abstract_catalog_reader_ty *catr, const char *s); +extern void default_comment_dot (abstract_catalog_reader_ty *catr, const char *s); -extern void default_comment_filepos (abstract_catalog_reader_ty *that, +extern void default_comment_filepos (abstract_catalog_reader_ty *catr, const char *file_name, size_t line_number); -extern void default_comment_special (abstract_catalog_reader_ty *that, +extern void default_comment_special (abstract_catalog_reader_ty *catr, const char *s); -extern void default_set_domain (default_catalog_reader_ty *this, char *name); -extern void default_add_message (default_catalog_reader_ty *this, +extern void default_set_domain (default_catalog_reader_ty *dcatr, char *name); +extern void default_add_message (default_catalog_reader_ty *dcatr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos, diff --git a/gettext-tools/src/read-po.c b/gettext-tools/src/read-po.c index e596d897a..c41558137 100644 --- a/gettext-tools/src/read-po.c +++ b/gettext-tools/src/read-po.c @@ -1,5 +1,5 @@ /* Reading PO files. - Copyright (C) 1995-1996, 1998, 2000-2006, 2023 Free Software Foundation, Inc. + Copyright (C) 1995-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,16 +24,11 @@ #include "po-lex.h" #include "po-gram.h" -/* For compiling this file in C++ mode. */ -#ifdef __cplusplus -# define this thiss -#endif - /* Read a .po / .pot file from a stream, and dispatch to the various abstract_catalog_reader_class_ty methods. */ static void -po_parse (abstract_catalog_reader_ty *this, FILE *fp, +po_parse (abstract_catalog_reader_ty *catr, FILE *fp, const char *real_filename, const char *logical_filename, bool is_pot_role) { diff --git a/gettext-tools/src/read-properties.c b/gettext-tools/src/read-properties.c index b89f75b27..1139c57d9 100644 --- a/gettext-tools/src/read-properties.c +++ b/gettext-tools/src/read-properties.c @@ -43,11 +43,6 @@ #define _(str) gettext (str) -/* For compiling this file in C++ mode. */ -#ifdef __cplusplus -# define this thiss -#endif - /* The format of the Java .properties files is documented in the JDK documentation for class java.util.Properties. In the case of .properties @@ -596,7 +591,7 @@ read_escaped_string (bool in_key) /* Read a .properties file from a stream, and dispatch to the various abstract_catalog_reader_class_ty methods. */ static void -properties_parse (abstract_catalog_reader_ty *this, FILE *file, +properties_parse (abstract_catalog_reader_ty *catr, FILE *file, const char *real_filename, const char *logical_filename, bool is_pot_role) { diff --git a/gettext-tools/src/read-stringtable.c b/gettext-tools/src/read-stringtable.c index 6df7d18e5..2a4e3d887 100644 --- a/gettext-tools/src/read-stringtable.c +++ b/gettext-tools/src/read-stringtable.c @@ -827,7 +827,7 @@ read_string (lex_pos_ty *pos) /* Read a .strings file from a stream, and dispatch to the various abstract_catalog_reader_class_ty methods. */ static void -stringtable_parse (abstract_catalog_reader_ty *pop, FILE *file, +stringtable_parse (abstract_catalog_reader_ty *catr, FILE *file, const char *real_filename, const char *logical_filename, bool is_pot_role) { diff --git a/gettext-tools/src/x-po.c b/gettext-tools/src/x-po.c index a91564535..89074da74 100644 --- a/gettext-tools/src/x-po.c +++ b/gettext-tools/src/x-po.c @@ -152,21 +152,21 @@ extract (FILE *fp, catalog_input_format_ty input_syntax, msgdomain_list_ty *mdlp) { - default_catalog_reader_ty *pop; + default_catalog_reader_ty *dcatr; header_charset = NULL; - pop = default_catalog_reader_alloc (&extract_methods); - pop->handle_comments = true; - pop->allow_domain_directives = false; - pop->allow_duplicates = false; - pop->allow_duplicates_if_same_msgstr = true; - pop->file_name = real_filename; - pop->mdlp = NULL; - pop->mlp = mdlp->item[0]->messages; - catalog_reader_parse ((abstract_catalog_reader_ty *) pop, fp, real_filename, + dcatr = default_catalog_reader_alloc (&extract_methods); + dcatr->handle_comments = true; + dcatr->allow_domain_directives = false; + dcatr->allow_duplicates = false; + dcatr->allow_duplicates_if_same_msgstr = true; + dcatr->file_name = real_filename; + dcatr->mdlp = NULL; + dcatr->mlp = mdlp->item[0]->messages; + catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename, logical_filename, true, input_syntax); - catalog_reader_free ((abstract_catalog_reader_ty *) pop); + catalog_reader_free ((abstract_catalog_reader_ty *) dcatr); if (header_charset != NULL) { diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index bbecfab46..a8109ba0f 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -1268,7 +1268,7 @@ or by email to <%s>.\n"), static void -exclude_directive_domain (abstract_catalog_reader_ty *pop, char *name) +exclude_directive_domain (abstract_catalog_reader_ty *catr, char *name) { po_gram_error_at_line (&gram_pos, _("this file may not contain domain directives")); @@ -1276,7 +1276,7 @@ exclude_directive_domain (abstract_catalog_reader_ty *pop, char *name) static void -exclude_directive_message (abstract_catalog_reader_ty *pop, +exclude_directive_message (abstract_catalog_reader_ty *catr, char *msgctxt, char *msgid, lex_pos_ty *msgid_pos,