summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src/read-catalog.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-01-29 17:22:14 +0900
committerDaiki Ueno <ueno@gnu.org>2015-03-03 18:55:59 +0900
commitd9fc3d2a3f43d4295db24883223dbe71ff8dd5d4 (patch)
tree57cd8eec96b44d272f35147676f08fe4a24de860 /gettext-tools/src/read-catalog.c
parent9e117619d848515c4ddbae18d05c0a66cf86a451 (diff)
downloadexternal_gettext-d9fc3d2a3f43d4295db24883223dbe71ff8dd5d4.zip
external_gettext-d9fc3d2a3f43d4295db24883223dbe71ff8dd5d4.tar.gz
external_gettext-d9fc3d2a3f43d4295db24883223dbe71ff8dd5d4.tar.bz2
xgettext: Support message syntax checks
With this change, xgettext could report common syntactic problems in extracted strings. The current built-in checks are ellipsis-unicode, space-ellipsis, and quote-unicode. Those checks can be enabled with --check option of xgettext and disabled with special "xgettext:" comment in source files. Feature suggested by Philip Withnall in: https://savannah.gnu.org/bugs/?44098 * gettext-tools/src/message.h (enum syntax_check_type): New enum. (NSYNTAXCHECKS): New constant. (enum is_syntax_check): New enum. (struct message_ty): New field 'do_syntax_check'. (syntax_check_name): New variable declaration. * gettext-tools/src/message.c (syntax_check_name): New variable. * gettext-tools/src/msgl-cat.c (catenate_msgdomain_list): Propagate mp->do_syntax_check. * gettext-tools/src/msgmerge.c (message_merge): Propagate ref->do_syntax_check. * gettext-tools/src/msgl-check.h (syntax_check_message_list): New declaration. * gettext-tools/src/msgl-check.c (sentence_end): New function. (syntax_check_ellipsis_unicode): New function. (syntax_check_space_ellipsis): New function. (syntax_check_quote_unicode): New function. (syntax_check_message): New function. (syntax_check_message_list): New function. * gettext-tools/src/read-catalog-abstract.h (po_parse_comment_special): Adjust function declaration. * gettext-tools/src/read-catalog-abstract.c (po_parse_comment_special): Add new argument SCP for syntax checking; all callers changed. * gettext-tools/src/read-catalog.h (DEFAULT_CATALOG_READER_TY): New field 'do_syntax_check'. * gettext-tools/src/read-catalog.c (default_constructor): Initialize this->do_syntax_check. (default_copy_comment_state): Propagate this->do_syntax_check. * gettext-tools/src/xgettext.c (long_options): Add --check option. (main): Handle --check option. (usage): Document --check option. (remember_a_message): Propagate do_syntax_check value. * gettext-tools/tests/xgettext-14: New file. * gettext-tools/tests/sentence.c: New file. * gettext-tools/tests/Makefile.am (TESTS): Add new test. (noinst_PROGRAMS): Add 'sentence'. (sentence_SOURCES): New variable. (sentence_CPPFLAGS): New variable. (sentence_LDADD): New variable. * gettext-tools/doc/xgettext.texi: Document --check option.
Diffstat (limited to 'gettext-tools/src/read-catalog.c')
-rw-r--r--gettext-tools/src/read-catalog.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gettext-tools/src/read-catalog.c b/gettext-tools/src/read-catalog.c
index 4642249..8c77df1 100644
--- a/gettext-tools/src/read-catalog.c
+++ b/gettext-tools/src/read-catalog.c
@@ -105,6 +105,8 @@ default_constructor (abstract_catalog_reader_ty *that)
this->range.min = -1;
this->range.max = -1;
this->do_wrap = undecided;
+ for (i = 0; i < NSYNTAXCHECKS; i++)
+ this->do_syntax_check[i] = undecided;
}
@@ -172,6 +174,8 @@ default_copy_comment_state (default_catalog_reader_ty *this, message_ty *mp)
mp->is_format[i] = this->is_format[i];
mp->range = this->range;
mp->do_wrap = this->do_wrap;
+ for (i = 0; i < NSYNTAXCHECKS; i++)
+ mp->do_syntax_check[i] = this->do_syntax_check[i];
}
@@ -205,6 +209,8 @@ default_reset_comment_state (default_catalog_reader_ty *this)
this->range.min = -1;
this->range.max = -1;
this->do_wrap = undecided;
+ for (i = 0; i < NSYNTAXCHECKS; i++)
+ this->do_syntax_check[i] = undecided;
}
@@ -299,7 +305,7 @@ default_comment_special (abstract_catalog_reader_ty *that, const char *s)
default_catalog_reader_ty *this = (default_catalog_reader_ty *) that;
po_parse_comment_special (s, &this->is_fuzzy, this->is_format, &this->range,
- &this->do_wrap);
+ &this->do_wrap, this->do_syntax_check);
}