* Programming languages support:
+ - C++ with Boost:
+ xgettext has a new option --boost that triggers the recognition and marking
+ of boost::format strings.
+
- Python:
xgettext now recognizes the source encoding from a "coding:" comment
among the first two lines. The default encoding is now ASCII, no longer
+2006-02-12 Bruno Haible <bruno@clisp.org>
+
+ * gettext.texi (PO Files): Mention boost-format.
+ (boost-format): New subsection.
+ * xgettext.texi: Document --boost option.
+
2005-11-29 Colin Watson <cjwatson@ubuntu.com>
* msggrep.texi: Document --invert-match option.
* php-format:: PHP Format Strings
* gcc-internal-format:: GCC internal Format Strings
* qt-format:: Qt Format Strings
+* boost-format:: Boost Format Strings
Individual Programming Languages
@kwindex no-qt-format@r{ flag}
Likewise for Qt, see @ref{qt-format}.
+@item boost-format
+@kwindex boost-format@r{ flag}
+@itemx no-boost-format
+@kwindex no-boost-format@r{ flag}
+Likewise for Boost, see @ref{boost-format}.
+
@end table
@kwindex msgctxt
* php-format:: PHP Format Strings
* gcc-internal-format:: GCC internal Format Strings
* qt-format:: Qt Format Strings
+* boost-format:: Boost Format Strings
@end menu
@node c-format, objc-format, Translators for other Languages, Translators for other Languages
@samp{P} denotes a function parameter, @samp{Q} denotes an assignment
operator, @samp{V} denotes a const/volatile qualifier.
-@node qt-format, , gcc-internal-format, Translators for other Languages
+@node qt-format, boost-format, gcc-internal-format, Translators for other Languages
@subsection Qt Format Strings
Qt format strings are described in the documentation of the QString class
In summary, a directive consists of a @samp{%} followed by a digit. The same
directive cannot occur more than once in a format string.
+@node boost-format, , qt-format, Translators for other Languages
+@subsection Boost Format Strings
+
+Boost format strings are described in the documentation of the
+@code{boost::format} class, at
+@uref{http://www.boost.org/libs/format/doc/format.html}.
+In summary, a directive has either the same syntax as in a C format string,
+such as @samp{%1$+5d}, or may be surrounded by vertical bars, such as
+@samp{%|1$+5d|} or @samp{%|1$+5|}, or consists of just an argument number
+between percent signs, such as @samp{%1%}.
+
@node Maintainers for other Languages, List of Programming Languages, Translators for other Languages, Programming Languages
@section The Maintainer's View
@*
This option has an effect only with the language C++.
+@item --boost
+@opindex --boost@r{, @code{xgettext} option}
+@cindex Boost format strings
+Recognize Boost format strings.
+@*
+This option has an effect only with the language C++.
+
@item --debug
@opindex --debug@r{, @code{xgettext} option}
@cindex debugging messages marked as format strings
+2006-02-12 Bruno Haible <bruno@clisp.org>
+
+ * message.h (format_type): New enum value 'format_boost'.
+ (NFORMATS): Increment.
+ * message.c (format_language): Add format_boost entry.
+ (format_language_pretty): Likewise.
+ * format.h (formatstring_boost): New declaration.
+ * format-boost.c: New file, based on format-c.c.
+ * format.c (formatstring_parsers): Add formatstring_boost.
+ * x-c.c (init_flag_table_c): Also register flags for boost-format.
+ * xgettext.c (flag_table_cxx_qt, flag_table_cxx_boost): New variables.
+ (recognize_format_boost): New variable.
+ (main): Handle --boost option.
+ (usage): Document --boost option.
+ (xgettext_record_flag): Also fill flag_table_cxx_qt,
+ flag_table_cxx_boost.
+ (remember_a_message, remember_a_message_plural): In the heuristics,
+ don't mark a string as c-format that is already known to be a qt-format
+ or boost-format.
+ (language_to_extractor): Use a flag_table_cxx_qt or
+ flag_table_cxx_boost that is different from flag_table_c.
+ * Makefile.am (FORMAT_SOURCE): Add format-boost.c.
+ * Makefile.msvc (OBJECTS): Add format-boost.obj.
+ (format-boost.obj): New rule.
+ * Makefile.vms (OBJECTS): Add format-boost.obj.
+ (format-boost.obj): New rule.
+ * FILES: Update.
+
2006-02-12 Bruno Haible <bruno@clisp.org>
* xgettext.c (xgettext_record_flag): When asked to set "qt-format",
format-php.c Format string handling for PHP.
format-gcc-internal.c Format string handling GCC internal.
format-qt.c Format string handling for Qt.
+format-boost.c Format string handling for Boost.
format.c Table of the language dependent format string handlers.
plural-exp.c
## Makefile for the gettext-tools/src subdirectory of GNU gettext
-## Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
+## Copyright (C) 1995-1998, 2000-2006 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
format-c.c format-sh.c format-python.c format-lisp.c format-elisp.c \
format-librep.c format-scheme.c format-java.c format-csharp.c format-awk.c \
format-pascal.c format-ycp.c format-tcl.c format-perl.c format-perl-brace.c \
-format-php.c format-gcc-internal.c format-qt.c
+format-php.c format-gcc-internal.c format-qt.c format-boost.c
# libgettextsrc contains all code that is needed by at least two programs.
libgettextsrc_la_SOURCES = \
format-perl-brace.obj \
format-php.obj \
format-gcc-internal.obj \
- format-qt.obj
+ format-qt.obj \
+ format-boost.obj
msgcmp_OBJECTS = msgcmp.obj
msgfmt_OBJECTS = msgfmt.obj write-mo.obj write-java.obj write-csharp.obj write-resources.obj write-tcl.obj write-qt.obj plural-eval.obj hash-string.obj
format-qt.obj : format-qt.c
$(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c format-qt.c
+format-boost.obj : format-boost.c
+ $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c format-boost.c
+
!if !$(DLL)
gettextsrc.lib : $(OBJECTS)
format-perl.obj, \
format-perl-brace.obj, \
format-php.obj, \
- format-gcc-internal.obj \
- format-qt.obj
+ format-gcc-internal.obj, \
+ format-qt.obj, \
+ format-boost.obj
msgcmp_OBJECTS = msgcmp.obj
msgfmt_OBJECTS = msgfmt.obj, write-mo.obj, write-java.obj, write-csharp.obj, write-resources.obj, write-tcl.obj, write-qt.obj, plural-eval.obj, hash-string.obj
format-qt.obj : format-qt.c
$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) format-qt.c
+format-boost.obj : format-boost.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) format-boost.c
+
gettextsrc.olb : $(OBJECTS)
$(AR) $(AR_FLAGS) gettextsrc.olb $(OBJECTS)
/* Format strings.
- Copyright (C) 2001-2005 Free Software Foundation, Inc.
+ Copyright (C) 2001-2006 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
/* format_perl_brace */ &formatstring_perl_brace,
/* format_php */ &formatstring_php,
/* format_gcc_internal */ &formatstring_gcc_internal,
- /* format_qt */ &formatstring_qt
+ /* format_qt */ &formatstring_qt,
+ /* format_boost */ &formatstring_boost
};
/* Check whether both formats strings contain compatible format
extern DLL_VARIABLE struct formatstring_parser formatstring_php;
extern DLL_VARIABLE struct formatstring_parser formatstring_gcc_internal;
extern DLL_VARIABLE struct formatstring_parser formatstring_qt;
+extern DLL_VARIABLE struct formatstring_parser formatstring_boost;
/* Table of all format string parsers. */
extern DLL_VARIABLE struct formatstring_parser *formatstring_parsers[NFORMATS];
/* GNU gettext - internationalization aids
- Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
/* format_perl_brace */ "perl-brace",
/* format_php */ "php",
/* format_gcc_internal */ "gcc-internal",
- /* format_qt */ "qt"
+ /* format_qt */ "qt",
+ /* format_boost */ "boost"
};
const char *const format_language_pretty[NFORMATS] =
/* format_perl_brace */ "Perl brace",
/* format_php */ "PHP",
/* format_gcc_internal */ "GCC internal",
- /* format_qt */ "Qt"
+ /* format_qt */ "Qt",
+ /* format_boost */ "Boost"
};
/* GNU gettext - internationalization aids
- Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
format_perl_brace,
format_php,
format_gcc_internal,
- format_qt
+ format_qt,
+ format_boost
};
-#define NFORMATS 20 /* Number of format_type enum values. */
+#define NFORMATS 21 /* Number of format_type enum values. */
extern DLL_VARIABLE const char *const format_language[NFORMATS];
extern DLL_VARIABLE const char *const format_language_pretty[NFORMATS];
/* xgettext C/C++/ObjectiveC backend.
- Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
xgettext_record_flag ("argp_error:2:c-format");
xgettext_record_flag ("argp_failure:2:c-format");
#endif
+
+ xgettext_record_flag ("gettext:1:pass-boost-format");
+ xgettext_record_flag ("dgettext:2:pass-boost-format");
+ xgettext_record_flag ("dcgettext:2:pass-boost-format");
+ xgettext_record_flag ("ngettext:1:pass-boost-format");
+ xgettext_record_flag ("ngettext:2:pass-boost-format");
+ xgettext_record_flag ("dngettext:2:pass-boost-format");
+ xgettext_record_flag ("dngettext:3:pass-boost-format");
+ xgettext_record_flag ("dcngettext:2:pass-boost-format");
+ xgettext_record_flag ("dcngettext:3:pass-boost-format");
+ xgettext_record_flag ("gettext_noop:1:pass-boost-format");
+ xgettext_record_flag ("pgettext:2:pass-boost-format");
+ xgettext_record_flag ("dpgettext:3:pass-boost-format");
+ xgettext_record_flag ("dcpgettext:3:pass-boost-format");
+ xgettext_record_flag ("npgettext:2:pass-boost-format");
+ xgettext_record_flag ("npgettext:3:pass-boost-format");
+ xgettext_record_flag ("dnpgettext:3:pass-boost-format");
+ xgettext_record_flag ("dnpgettext:4:pass-boost-format");
+ xgettext_record_flag ("dcnpgettext:3:pass-boost-format");
+ xgettext_record_flag ("dcnpgettext:4:pass-boost-format");
+
+ /* <boost/format.hpp> */
+ xgettext_record_flag ("format:1:boost-format");
}
void
/* Table of flag_context_list_ty tables. */
static flag_context_list_table_ty flag_table_c;
+static flag_context_list_table_ty flag_table_cxx_qt;
+static flag_context_list_table_ty flag_table_cxx_boost;
static flag_context_list_table_ty flag_table_objc;
static flag_context_list_table_ty flag_table_gcc_internal;
static flag_context_list_table_ty flag_table_sh;
/* If true, recognize Qt format strings. */
static bool recognize_format_qt;
+/* If true, recognize Boost format strings. */
+static bool recognize_format_boost;
+
/* Canonicalized encoding name for all input files. */
const char *xgettext_global_source_encoding;
{
{ "add-comments", optional_argument, NULL, 'c' },
{ "add-location", no_argument, &line_comment, 1 },
+ { "boost", no_argument, NULL, CHAR_MAX + 10 },
{ "c++", no_argument, NULL, 'C' },
{ "copyright-holder", required_argument, NULL, CHAR_MAX + 1 },
{ "debug", no_argument, &do_debug, 1 },
case CHAR_MAX + 9: /* --qt */
recognize_format_qt = true;
break;
+ case CHAR_MAX + 10: /* --boost */
+ recognize_format_boost = true;
+ break;
default:
usage (EXIT_FAILURE);
/* NOTREACHED */
error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
"--sort-output", "--sort-by-file");
+ if (recognize_format_qt && recognize_format_boost)
+ /* We cannot support both Qt and Boost format strings, because there are
+ only two formatstring parsers per language, and formatstring_c is the
+ first one for C++. */
+ error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
+ "--qt", "--boost");
+
if (join_existing && strcmp (default_domain, "-") == 0)
error (EXIT_FAILURE, 0, _("\
--join-existing cannot be used when output is written to stdout"));
printf (_("\
(only language C++)\n"));
printf (_("\
+ --boost recognize Boost format strings\n"));
+ printf (_("\
+ (only language C++)\n"));
+ printf (_("\
--debug more detailed formatstring recognition result\n"));
printf ("\n");
printf (_("\
flag_context_list_table_insert (&flag_table_c, 0,
name_start, name_end,
argnum, value, pass);
+ flag_context_list_table_insert (&flag_table_cxx_qt, 0,
+ name_start, name_end,
+ argnum, value, pass);
+ flag_context_list_table_insert (&flag_table_cxx_boost, 0,
+ name_start, name_end,
+ argnum, value, pass);
flag_context_list_table_insert (&flag_table_objc, 0,
name_start, name_end,
argnum, value, pass);
argnum, value, pass);
break;
case format_qt:
- flag_context_list_table_insert (&flag_table_c, 1,
+ flag_context_list_table_insert (&flag_table_cxx_qt, 1,
+ name_start, name_end,
+ argnum, value, pass);
+ break;
+ case format_boost:
+ flag_context_list_table_insert (&flag_table_cxx_boost, 1,
name_start, name_end,
argnum, value, pass);
break;
|| formatstring_parsers[i] == current_formatstring_parser2)
/* But avoid redundancy: objc-format is stronger than c-format. */
&& !(i == format_c && possible_format_p (is_format[format_objc]))
- && !(i == format_objc && possible_format_p (is_format[format_c])))
+ && !(i == format_objc && possible_format_p (is_format[format_c]))
+ /* Avoid flagging a string as c-format when it's known to be a
+ qt-format or boost-format string. */
+ && !(i == format_c
+ && (possible_format_p (is_format[format_qt])
+ || possible_format_p (is_format[format_boost]))))
{
struct formatstring_parser *parser = formatstring_parsers[i];
char *invalid_reason = NULL;
&& !(i == format_c
&& possible_format_p (mp->is_format[format_objc]))
&& !(i == format_objc
- && possible_format_p (mp->is_format[format_c])))
+ && possible_format_p (mp->is_format[format_c]))
+ /* Avoid flagging a string as c-format when it's known to be a
+ qt-format or boost-format string. */
+ && !(i == format_c
+ && (possible_format_p (mp->is_format[format_qt])
+ || possible_format_p (mp->is_format[format_boost]))))
{
struct formatstring_parser *parser = formatstring_parsers[i];
char *invalid_reason = NULL;
than through an option --language=C++/Qt because the latter would
conflict with the language "C++" regarding the file extensions. */
if (recognize_format_qt && strcmp (tp->name, "C++") == 0)
- result.formatstring_parser2 = &formatstring_qt;
+ {
+ result.flag_table = &flag_table_cxx_qt;
+ result.formatstring_parser2 = &formatstring_qt;
+ }
+ /* Likewise for --boost. */
+ if (recognize_format_boost && strcmp (tp->name, "C++") == 0)
+ {
+ result.flag_table = &flag_table_cxx_boost;
+ result.formatstring_parser2 = &formatstring_boost;
+ }
return result;
}
+2006-02-12 Bruno Haible <bruno@clisp.org>
+
+ * xgettext-c-14: New file.
+ * format-boost-1: New file.
+ * format-boost-2: New file.
+ * Makefile.am (TESTS): Add them.
+
2006-02-12 Bruno Haible <bruno@clisp.org>
* xgettext-c-13: New file.
xgettext-awk-1 \
xgettext-c-1 xgettext-c-2 xgettext-c-3 xgettext-c-4 xgettext-c-5 \
xgettext-c-6 xgettext-c-7 xgettext-c-8 xgettext-c-9 xgettext-c-10 \
- xgettext-c-11 xgettext-c-12 xgettext-c-13 \
+ xgettext-c-11 xgettext-c-12 xgettext-c-13 xgettext-c-14 \
xgettext-csharp-1 xgettext-csharp-2 xgettext-csharp-3 \
xgettext-csharp-4 xgettext-csharp-5 \
xgettext-elisp-1 \
xgettext-tcl-1 xgettext-tcl-2 \
xgettext-ycp-1 xgettext-ycp-2 \
format-awk-1 format-awk-2 \
+ format-boost-1 format-boost-2 \
format-c-1 format-c-2 format-c-3 format-c-4 format-c-5 \
format-csharp-1 format-csharp-2 \
format-elisp-1 format-elisp-2 \