diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..058190a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/gettext-0.19.8.1.tar.xz diff --git a/EMPTY b/EMPTY deleted file mode 100644 index 0519ecb..0000000 --- a/EMPTY +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/disable-gettext-runtime-test-lock.patch b/disable-gettext-runtime-test-lock.patch new file mode 100644 index 0000000..ec3a59b --- /dev/null +++ b/disable-gettext-runtime-test-lock.patch @@ -0,0 +1,47 @@ +commit bd2c6ca2b7ae0be02d4bb85db79def454f3153fb +Author: rpm-build +AuthorDate: Wed Dec 21 12:50:54 2016 +0100 +Commit: rpm-build +CommitDate: Wed Dec 21 12:52:36 2016 +0100 + + disable-gettext-runtime-test-lock.patch + +diff --git a/gettext-runtime/tests/Makefile.am b/gettext-runtime/tests/Makefile.am +index 88a0684..3a27b79 100644 +--- a/gettext-runtime/tests/Makefile.am ++++ b/gettext-runtime/tests/Makefile.am +@@ -19,7 +19,7 @@ + AUTOMAKE_OPTIONS = 1.11 gnits no-dependencies color-tests subdir-objects + EXTRA_DIST = + +-TESTS = test-lock ++TESTS = + + AM_CPPFLAGS = \ + -I.. \ +diff --git a/gettext-runtime/tests/Makefile.in b/gettext-runtime/tests/Makefile.in +index 4327733..5879146 100644 +--- a/gettext-runtime/tests/Makefile.in ++++ b/gettext-runtime/tests/Makefile.in +@@ -86,7 +86,7 @@ PRE_UNINSTALL = : + POST_UNINSTALL = : + build_triplet = @build@ + host_triplet = @host@ +-TESTS = test-lock$(EXEEXT) ++TESTS = + check_PROGRAMS = test-lock$(EXEEXT) + subdir = tests + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +diff --git a/gettext-tools/gnulib-tests/Makefile.in b/gettext-tools/gnulib-tests/Makefile.in +index 26becd9..4b9d0e4 100644 +--- a/gettext-tools/gnulib-tests/Makefile.in ++++ b/gettext-tools/gnulib-tests/Makefile.in +@@ -143,7 +143,7 @@ TESTS = test-set-mode-acl.sh test-set-mode-acl-1.sh \ + test-isnanl-nolibm$(EXEEXT) test-isnanl$(EXEEXT) \ + test-iswblank$(EXEEXT) test-langinfo$(EXEEXT) \ + test-linkedhash_list$(EXEEXT) test-locale$(EXEEXT) \ +- test-localename$(EXEEXT) test-lock$(EXEEXT) \ ++ test-localename$(EXEEXT) \ + test-log10$(EXEEXT) test-lseek.sh test-lstat$(EXEEXT) \ + test-malloca$(EXEEXT) test-math$(EXEEXT) test-mbrtowc1.sh \ + test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \ diff --git a/gettext-0.19.8-its-segfault.patch b/gettext-0.19.8-its-segfault.patch new file mode 100644 index 0000000..430719f --- /dev/null +++ b/gettext-0.19.8-its-segfault.patch @@ -0,0 +1,43 @@ +From a0cab23332a254e3500cac2a3a984472d02180e5 Mon Sep 17 00:00:00 2001 +From: Bruno Haible +Date: Fri, 9 Dec 2016 21:04:31 +0100 +Subject: [PATCH] Fix crash of xgettext with --its option. + +* gettext-tools/src/xgettext.c (main): Free contents of its_dirs only when it +was initialized. Fixes bug introduced on 2016-05-16. +--- + gettext-tools/src/xgettext.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c +index f848d76d1..a80ee51ac 100644 +--- a/gettext-tools/src/xgettext.c ++++ b/gettext-tools/src/xgettext.c +@@ -330,7 +330,7 @@ main (int argc, char *argv[]) + bool sort_by_msgid = false; + bool sort_by_filepos = false; + char **dirs; +- char **its_dirs; ++ char **its_dirs = NULL; + char *explicit_its_filename = NULL; + const char *file_name; + const char *files_from = NULL; +@@ -1016,9 +1016,12 @@ warning: file '%s' extension '%s' is unknown; will try C"), filename, extension) + if (its_locating_rules) + locating_rule_list_free (its_locating_rules); + +- for (i = 0; its_dirs[i] != NULL; i++) +- free (its_dirs[i]); +- free (its_dirs); ++ if (its_dirs != NULL) ++ { ++ for (i = 0; its_dirs[i] != NULL; i++) ++ free (its_dirs[i]); ++ free (its_dirs); ++ } + + exit (EXIT_SUCCESS); + } +-- +2.14.3 + diff --git a/gettext-0.19.8.1-CVE-2018-18751.patch b/gettext-0.19.8.1-CVE-2018-18751.patch new file mode 100644 index 0000000..a857738 --- /dev/null +++ b/gettext-0.19.8.1-CVE-2018-18751.patch @@ -0,0 +1,445 @@ +From dce3a16e5e9368245735e29bf498dcd5e3e474a4 Mon Sep 17 00:00:00 2001 +From: Daiki Ueno +Date: Thu, 15 Sep 2016 13:57:24 +0200 +Subject: [PATCH] xgettext: Fix crash with *.po file input + +When xgettext was given two *.po files with the same msgid_plural, it +crashed with double-free. Problem reported by Davlet Panech in: +http://lists.gnu.org/archive/html/bug-gettext/2016-09/msg00001.html + +praiskup: +- I dropped the testsuite part, otherwise we'd have to 'autoreconf -vif' the + sources +- I'm patching manually the po-gram-gen.c file to avoid 'bison' BR + +diff --git a/gettext-tools/src/po-gram-gen.y b/gettext-tools/src/po-gram-gen.y +index becf5e607..4428e7725 100644 +--- a/gettext-tools/src/po-gram-gen.y ++++ b/gettext-tools/src/po-gram-gen.y +@@ -221,14 +221,11 @@ message + check_obsolete ($1, $3); + check_obsolete ($1, $4); + if (!$1.obsolete || pass_obsolete_entries) +- { +- do_callback_message ($1.ctxt, string2, &$1.pos, $3.string, +- $4.rhs.msgstr, $4.rhs.msgstr_len, &$4.pos, +- $1.prev_ctxt, +- $1.prev_id, $1.prev_id_plural, +- $1.obsolete); +- free ($3.string); +- } ++ do_callback_message ($1.ctxt, string2, &$1.pos, $3.string, ++ $4.rhs.msgstr, $4.rhs.msgstr_len, &$4.pos, ++ $1.prev_ctxt, ++ $1.prev_id, $1.prev_id_plural, ++ $1.obsolete); + else + { + free_message_intro ($1); +diff --git a/gettext-tools/src/read-catalog.c b/gettext-tools/src/read-catalog.c +index 571d18e1b..6af6d2025 100644 +--- a/gettext-tools/src/read-catalog.c ++++ b/gettext-tools/src/read-catalog.c +@@ -397,6 +397,8 @@ default_add_message (default_catalog_reader_ty *this, + appropriate. */ + mp = message_alloc (msgctxt, msgid, msgid_plural, msgstr, msgstr_len, + msgstr_pos); ++ if (msgid_plural != NULL) ++ free (msgid_plural); + mp->prev_msgctxt = prev_msgctxt; + mp->prev_msgid = prev_msgid; + mp->prev_msgid_plural = prev_msgid_plural; +diff --git a/gettext-tools/src/po-gram-gen.c b/gettext-tools/src/po-gram-gen.c +--- a/gettext-tools/src/po-gram-gen.c ++++ b/gettext-tools/src/po-gram-gen.c +@@ -1,8 +1,8 @@ +-/* A Bison parser, made by GNU Bison 3.0.4. */ ++/* A Bison parser, made by GNU Bison 3.0.5. */ + + /* Bison implementation for Yacc-like parsers in C + +- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. ++ Copyright (C) 1984, 1989-1990, 2000-2015, 2018 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 +@@ -44,7 +44,7 @@ + #define YYBISON 1 + + /* Bison version. */ +-#define YYBISON_VERSION "3.0.4" ++#define YYBISON_VERSION "3.0.5" + + /* Skeleton name. */ + #define YYSKELETON_NAME "yacc.c" +@@ -568,9 +568,9 @@ + static const yytype_uint16 yyrline[] = + { + 0, 169, 169, 171, 172, 173, 174, 179, 187, 195, +- 216, 240, 249, 258, 269, 278, 292, 301, 315, 321, +- 332, 338, 350, 361, 372, 376, 391, 414, 422, 434, +- 442 ++ 216, 237, 246, 255, 266, 275, 289, 298, 312, 318, ++ 329, 335, 347, 358, 369, 373, 388, 411, 419, 431, ++ 439 + }; + #endif + +@@ -1054,6 +1054,7 @@ + case N: \ + yyformat = S; \ + break ++ default: /* Avoid compiler warnings. */ + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); +@@ -1370,23 +1371,23 @@ + switch (yyn) + { + case 7: +-#line 180 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 180 "po-gram-gen.y" /* yacc.c:1648 */ + { + po_callback_comment_dispatcher ((yyvsp[0].string).string); + } +-#line 1378 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1379 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 8: +-#line 188 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 188 "po-gram-gen.y" /* yacc.c:1648 */ + { + po_callback_domain ((yyvsp[0].string).string); + } +-#line 1386 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1387 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 9: +-#line 196 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 196 "po-gram-gen.y" /* yacc.c:1648 */ + { + char *string2 = string_list_concat_destroy (&(yyvsp[-2].stringlist).stringlist); + char *string4 = string_list_concat_destroy (&(yyvsp[0].stringlist).stringlist); +@@ -1407,11 +1408,11 @@ + free (string4); + } + } +-#line 1411 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1412 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 10: +-#line 217 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 217 "po-gram-gen.y" /* yacc.c:1648 */ + { + char *string2 = string_list_concat_destroy (&(yyvsp[-2].stringlist).stringlist); + +@@ -1419,14 +1420,11 @@ + check_obsolete ((yyvsp[-3].message_intro), (yyvsp[-1].string)); + check_obsolete ((yyvsp[-3].message_intro), (yyvsp[0].rhs)); + if (!(yyvsp[-3].message_intro).obsolete || pass_obsolete_entries) +- { +- do_callback_message ((yyvsp[-3].message_intro).ctxt, string2, &(yyvsp[-3].message_intro).pos, (yyvsp[-1].string).string, +- (yyvsp[0].rhs).rhs.msgstr, (yyvsp[0].rhs).rhs.msgstr_len, &(yyvsp[0].rhs).pos, +- (yyvsp[-3].message_intro).prev_ctxt, +- (yyvsp[-3].message_intro).prev_id, (yyvsp[-3].message_intro).prev_id_plural, +- (yyvsp[-3].message_intro).obsolete); +- free ((yyvsp[-1].string).string); +- } ++ do_callback_message ((yyvsp[-3].message_intro).ctxt, string2, &(yyvsp[-3].message_intro).pos, (yyvsp[-1].string).string, ++ (yyvsp[0].rhs).rhs.msgstr, (yyvsp[0].rhs).rhs.msgstr_len, &(yyvsp[0].rhs).pos, ++ (yyvsp[-3].message_intro).prev_ctxt, ++ (yyvsp[-3].message_intro).prev_id, (yyvsp[-3].message_intro).prev_id_plural, ++ (yyvsp[-3].message_intro).obsolete); + else + { + free_message_intro ((yyvsp[-3].message_intro)); +@@ -1435,11 +1433,11 @@ + free ((yyvsp[0].rhs).rhs.msgstr); + } + } +-#line 1439 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1437 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 11: +-#line 241 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 238 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-2].message_intro), (yyvsp[-1].stringlist)); + check_obsolete ((yyvsp[-2].message_intro), (yyvsp[0].string)); +@@ -1448,11 +1446,11 @@ + string_list_destroy (&(yyvsp[-1].stringlist).stringlist); + free ((yyvsp[0].string).string); + } +-#line 1452 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1450 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 12: +-#line 250 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 247 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-2].message_intro), (yyvsp[-1].stringlist)); + check_obsolete ((yyvsp[-2].message_intro), (yyvsp[0].rhs)); +@@ -1461,22 +1459,22 @@ + string_list_destroy (&(yyvsp[-1].stringlist).stringlist); + free ((yyvsp[0].rhs).rhs.msgstr); + } +-#line 1465 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1463 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 13: +-#line 259 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 256 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].message_intro), (yyvsp[0].stringlist)); + po_gram_error_at_line (&(yyvsp[-1].message_intro).pos, _("missing 'msgstr' section")); + free_message_intro ((yyvsp[-1].message_intro)); + string_list_destroy (&(yyvsp[0].stringlist).stringlist); + } +-#line 1476 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1474 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 14: +-#line 270 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 267 "po-gram-gen.y" /* yacc.c:1648 */ + { + (yyval.message_intro).prev_ctxt = NULL; + (yyval.message_intro).prev_id = NULL; +@@ -1485,11 +1483,11 @@ + (yyval.message_intro).pos = (yyvsp[0].string).pos; + (yyval.message_intro).obsolete = (yyvsp[0].string).obsolete; + } +-#line 1489 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1487 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 15: +-#line 279 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 276 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].prev), (yyvsp[0].string)); + (yyval.message_intro).prev_ctxt = (yyvsp[-1].prev).ctxt; +@@ -1499,11 +1497,11 @@ + (yyval.message_intro).pos = (yyvsp[0].string).pos; + (yyval.message_intro).obsolete = (yyvsp[0].string).obsolete; + } +-#line 1503 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1501 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 16: +-#line 293 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 290 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].string), (yyvsp[0].stringlist)); + (yyval.prev).ctxt = (yyvsp[-1].string).string; +@@ -1512,11 +1510,11 @@ + (yyval.prev).pos = (yyvsp[-1].string).pos; + (yyval.prev).obsolete = (yyvsp[-1].string).obsolete; + } +-#line 1516 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1514 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 17: +-#line 302 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 299 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-2].string), (yyvsp[-1].stringlist)); + check_obsolete ((yyvsp[-2].string), (yyvsp[0].string)); +@@ -1526,21 +1524,21 @@ + (yyval.prev).pos = (yyvsp[-2].string).pos; + (yyval.prev).obsolete = (yyvsp[-2].string).obsolete; + } +-#line 1530 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1528 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 18: +-#line 316 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 313 "po-gram-gen.y" /* yacc.c:1648 */ + { + (yyval.string).string = NULL; + (yyval.string).pos = (yyvsp[0].pos).pos; + (yyval.string).obsolete = (yyvsp[0].pos).obsolete; + } +-#line 1540 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1538 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 19: +-#line 322 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 319 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-2].pos), (yyvsp[-1].stringlist)); + check_obsolete ((yyvsp[-2].pos), (yyvsp[0].pos)); +@@ -1548,21 +1546,21 @@ + (yyval.string).pos = (yyvsp[0].pos).pos; + (yyval.string).obsolete = (yyvsp[0].pos).obsolete; + } +-#line 1552 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1550 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 20: +-#line 333 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 330 "po-gram-gen.y" /* yacc.c:1648 */ + { + (yyval.string).string = NULL; + (yyval.string).pos = (yyvsp[0].pos).pos; + (yyval.string).obsolete = (yyvsp[0].pos).obsolete; + } +-#line 1562 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1560 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 21: +-#line 339 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 336 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-2].pos), (yyvsp[-1].stringlist)); + check_obsolete ((yyvsp[-2].pos), (yyvsp[0].pos)); +@@ -1570,11 +1568,11 @@ + (yyval.string).pos = (yyvsp[0].pos).pos; + (yyval.string).obsolete = (yyvsp[0].pos).obsolete; + } +-#line 1574 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1572 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 22: +-#line 351 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 348 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].pos), (yyvsp[0].stringlist)); + plural_counter = 0; +@@ -1582,30 +1580,30 @@ + (yyval.string).pos = (yyvsp[-1].pos).pos; + (yyval.string).obsolete = (yyvsp[-1].pos).obsolete; + } +-#line 1586 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1584 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 23: +-#line 362 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 359 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].pos), (yyvsp[0].stringlist)); + (yyval.string).string = string_list_concat_destroy (&(yyvsp[0].stringlist).stringlist); + (yyval.string).pos = (yyvsp[-1].pos).pos; + (yyval.string).obsolete = (yyvsp[-1].pos).obsolete; + } +-#line 1597 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1595 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 24: +-#line 373 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 370 "po-gram-gen.y" /* yacc.c:1648 */ + { + (yyval.rhs) = (yyvsp[0].rhs); + } +-#line 1605 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1603 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 25: +-#line 377 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 374 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].rhs), (yyvsp[0].rhs)); + (yyval.rhs).rhs.msgstr = XNMALLOC ((yyvsp[-1].rhs).rhs.msgstr_len + (yyvsp[0].rhs).rhs.msgstr_len, char); +@@ -1617,11 +1615,11 @@ + (yyval.rhs).pos = (yyvsp[-1].rhs).pos; + (yyval.rhs).obsolete = (yyvsp[-1].rhs).obsolete; + } +-#line 1621 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1619 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 26: +-#line 392 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 389 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-4].pos), (yyvsp[-3].pos)); + check_obsolete ((yyvsp[-4].pos), (yyvsp[-2].number)); +@@ -1640,11 +1638,11 @@ + (yyval.rhs).pos = (yyvsp[-4].pos).pos; + (yyval.rhs).obsolete = (yyvsp[-4].pos).obsolete; + } +-#line 1644 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1642 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 27: +-#line 415 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 412 "po-gram-gen.y" /* yacc.c:1648 */ + { + string_list_init (&(yyval.stringlist).stringlist); + string_list_append (&(yyval.stringlist).stringlist, (yyvsp[0].string).string); +@@ -1652,11 +1650,11 @@ + (yyval.stringlist).pos = (yyvsp[0].string).pos; + (yyval.stringlist).obsolete = (yyvsp[0].string).obsolete; + } +-#line 1656 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1654 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 28: +-#line 423 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 420 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].stringlist), (yyvsp[0].string)); + (yyval.stringlist).stringlist = (yyvsp[-1].stringlist).stringlist; +@@ -1665,11 +1663,11 @@ + (yyval.stringlist).pos = (yyvsp[-1].stringlist).pos; + (yyval.stringlist).obsolete = (yyvsp[-1].stringlist).obsolete; + } +-#line 1669 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1667 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 29: +-#line 435 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 432 "po-gram-gen.y" /* yacc.c:1648 */ + { + string_list_init (&(yyval.stringlist).stringlist); + string_list_append (&(yyval.stringlist).stringlist, (yyvsp[0].string).string); +@@ -1677,11 +1675,11 @@ + (yyval.stringlist).pos = (yyvsp[0].string).pos; + (yyval.stringlist).obsolete = (yyvsp[0].string).obsolete; + } +-#line 1681 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1679 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + case 30: +-#line 443 "po-gram-gen.y" /* yacc.c:1646 */ ++#line 440 "po-gram-gen.y" /* yacc.c:1648 */ + { + check_obsolete ((yyvsp[-1].stringlist), (yyvsp[0].string)); + (yyval.stringlist).stringlist = (yyvsp[-1].stringlist).stringlist; +@@ -1690,11 +1688,11 @@ + (yyval.stringlist).pos = (yyvsp[-1].stringlist).pos; + (yyval.stringlist).obsolete = (yyvsp[-1].stringlist).obsolete; + } +-#line 1694 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1692 "po-gram-gen.c" /* yacc.c:1648 */ + break; + + +-#line 1698 "po-gram-gen.c" /* yacc.c:1646 */ ++#line 1696 "po-gram-gen.c" /* yacc.c:1648 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires +-- +2.19.1 + diff --git a/gettext-po-send-mail.patch b/gettext-po-send-mail.patch new file mode 100644 index 0000000..2602e1d --- /dev/null +++ b/gettext-po-send-mail.patch @@ -0,0 +1,21 @@ +Index: gettext-0.19.8.1/gettext-tools/misc/po-mode.el +=================================================================== +--- gettext-0.19.8.1.orig/gettext-tools/misc/po-mode.el ++++ gettext-0.19.8.1/gettext-tools/misc/po-mode.el +@@ -3518,10 +3518,12 @@ Write to your team? ('n' if writing to + (re-search-forward + (concat "^" (regexp-quote mail-header-separator) "\n")) + (save-excursion +- (insert-buffer-substring buffer) +- (shell-command-on-region +- (region-beginning) (region-end) +- (concat po-gzip-uuencode-command " " name ".gz") t t)))))) ++ (save-restriction ++ (narrow-to-region (point) (point)) ++ (insert-buffer-substring buffer) ++ (shell-command-on-region ++ (point-min) (point-max) ++ (concat po-gzip-uuencode-command " " name ".gz") t t))))))) + (message "")) + + (defun po-confirm-and-quit () diff --git a/gettext.spec b/gettext.spec new file mode 100644 index 0000000..826ea95 --- /dev/null +++ b/gettext.spec @@ -0,0 +1,1050 @@ +%bcond_with jar +%bcond_with java +%bcond_without check + +%global tarversion 0.19.8.1 +%global archiveversion 0.19.8 + +Summary: GNU libraries and utilities for producing multi-lingual messages +Name: gettext +Version: 0.19.8.1 +Release: 17%{?dist} +License: GPLv3+ and LGPLv2+ +Group: Development/Tools +URL: http://www.gnu.org/software/gettext/ +Source: ftp://ftp.gnu.org/gnu/gettext/%{name}-%{tarversion}.tar.xz +# Disable the test_lock test as it often hangs on a number of arches +# https://bugzilla.redhat.com/show_bug.cgi?id=1155291 +# http://savannah.gnu.org/bugs/?43487 +Patch0: disable-gettext-runtime-test-lock.patch +# Upstreamed patch: +# http://lists.gnu.org/archive/html/bug-gettext/2016-08/msg00006.html +Patch1: gettext-po-send-mail.patch +# Rhbz#1531476, upstream a0cab23332a254e3500cac2a3a984472d02180e5 +Patch2: gettext-0.19.8-its-segfault.patch +# rhbz#1647044 +Patch3: gettext-0.19.8.1-CVE-2018-18751.patch + +Source2: msghack.py +Source3: msghack.1 +# for bootstrapping +# BuildRequires: autoconf >= 2.62 +# BuildRequires: automake +# BuildRequires: libtool +# BuildRequires: bison + +BuildRequires: gcc-c++ +%if %{with java} +# libintl.jar requires gcj >= 4.3 to build +BuildRequires: gcc-java, libgcj +# For javadoc +BuildRequires: java-1.6.0-openjdk-devel +%if %{with jar} +BuildRequires: %{_bindir}/fastjar +# require zip and unzip for brp-java-repack-jars +BuildRequires: zip, unzip +%endif +%endif +# for po-mode.el +BuildRequires: emacs +# for autosetup +BuildRequires: git +# ensure 'ARCHIVE_FORMAT=dirxz' +BuildRequires: xz +BuildRequires: chrpath +# following suggested by DEPENDENCIES: +BuildRequires: ncurses-devel +BuildRequires: libxml2-devel +BuildRequires: glib2-devel +BuildRequires: libcroco-devel +BuildRequires: libunistring-devel +Requires(post): info +Requires(preun): info +# Depend on the exact version of the library sub package +Requires: %{name}-libs%{_isa} = %{version}-%{release} +# for F17 UsrMove +Conflicts: filesystem < 3 +Provides: /bin/gettext +# exception for bundled gnulib copylib +Provides: bundled(gnulib) + +%description +The GNU gettext package provides a set of tools and documentation for +producing multi-lingual messages in programs. Tools include a set of +conventions about how programs should be written to support message +catalogs, a directory and file naming organization for the message +catalogs, a runtime library which supports the retrieval of translated +messages, and stand-alone programs for handling the translatable and +the already translated strings. Gettext provides an easy to use +library and tools for creating, using, and modifying natural language +catalogs and is a powerful and simple method for internationalizing +programs. + + +%package common-devel +Summary: Common development files for %{name} +Group: Development/Tools +# autopoint archive +License: GPLv3+ +BuildArch: noarch + +%description common-devel +This package contains common architecture independent gettext development files. + + +%package devel +Summary: Development files for %{name} +Group: Development/Tools +# autopoint is GPLv3+ +# libasprintf is LGPLv2+ +# libgettextpo is GPLv3+ +License: LGPLv2+ and GPLv3+ +Requires: %{name} = %{version}-%{release} +Requires: %{name}-libs = %{version}-%{release} +Requires: %{name}-common-devel = %{version}-%{release} +Requires(post): info +Requires(preun): info +Requires: xz +Obsoletes: gettext-autopoint < 0.18.1.1-3 +Provides: gettext-autopoint = %{version}-%{release} + +%description devel +This package contains all development related files necessary for +developing or compiling applications/libraries that needs +internationalization capability. You also need this package if you +want to add gettext support for your project. + + +%package libs +Summary: Libraries for %{name} +Group: System Environment/Libraries +# libasprintf is LGPLv2+ +# libgettextpo is GPLv3+ +License: LGPLv2+ and GPLv3+ + +%description libs +This package contains libraries used internationalization support. + + +%package -n emacs-%{name} +Summary: Support for editing po files within GNU Emacs +Group: Applications/Editors +BuildArch: noarch +# help users find po-mode.el +Provides: emacs-po-mode +Requires: emacs(bin) >= %{_emacs_version} +Provides: emacs-%{name}-el = %{version}-%{release} +Obsoletes: emacs-%{name}-el < %{version}-%{release} + +%description -n emacs-%{name} +This package provides a major mode for editing po files within GNU Emacs. + +%package -n msghack +Summary: Alter PO files in ways +BuildArch: noarch + +%description -n msghack +This program can be used to alter .po files in ways no sane mind would +think about. + + +%prep +%autosetup -n %{name}-%{tarversion} -S git + + +%build +%if %{with java} +export JAVAC=gcj +%if %{with jar} +export JAR=fastjar +%endif +%endif +%ifarch ppc ppc64 ppc64le +# prevent test-isinf from failing with gcc-5.3.1 on ppc64le (#1294016) +export CFLAGS="$RPM_OPT_FLAGS -D__SUPPORT_SNAN__" +%endif +# --disable-rpath doesn't work properly on lib64 +%configure --without-included-gettext --enable-nls --disable-static \ + --enable-shared --with-pic --disable-csharp --disable-rpath \ +%if %{with java} + --enable-java \ +%else + --disable-java --disable-native-java \ +%endif + --with-xz + +make %{?_smp_mflags} %{?with_java:GCJFLAGS="-findirect-dispatch"} + + +%install +make install DESTDIR=${RPM_BUILD_ROOT} INSTALL="%{__install} -p" \ + lispdir=%{_datadir}/emacs/site-lisp/gettext \ + aclocaldir=%{_datadir}/aclocal EXAMPLESFILES="" + + +install -pm 755 %SOURCE2 ${RPM_BUILD_ROOT}/%{_bindir}/msghack +install -pm 644 %SOURCE3 ${RPM_BUILD_ROOT}/%{_mandir}/man1/msghack.1 + + +# make preloadable_libintl.so executable +chmod 755 ${RPM_BUILD_ROOT}%{_libdir}/preloadable_libintl.so + +rm -f ${RPM_BUILD_ROOT}%{_infodir}/dir + +# doc relocations +for i in gettext-runtime/man/*.html; do + rm ${RPM_BUILD_ROOT}%{_datadir}/doc/gettext/`basename $i` +done +rm -r ${RPM_BUILD_ROOT}%{_datadir}/doc/gettext/javadoc* + +rm -rf ${RPM_BUILD_ROOT}%{_datadir}/doc/gettext/examples + +rm -rf htmldoc +mkdir htmldoc +mv ${RPM_BUILD_ROOT}%{_datadir}/doc/gettext/* ${RPM_BUILD_ROOT}/%{_datadir}/doc/libasprintf/* htmldoc +rm -r ${RPM_BUILD_ROOT}%{_datadir}/doc/libasprintf +rm -r ${RPM_BUILD_ROOT}%{_datadir}/doc/gettext + +## note libintl.jar does not build with gcj < 4.3 +## since it would not be fully portable +%if %{with jar} +### this is no longer needed since examples not packaged +## set timestamp of examples ChangeLog timestamp for brp-java-repack-jars +#for i in `find ${RPM_BUILD_ROOT} examples -newer ChangeLog -type f -name ChangeLog`; do +# touch -r ChangeLog $i +#done +%else +# in case another java compiler is installed +rm -f ${RPM_BUILD_ROOT}%{_datadir}/%{name}/libintl.jar +%endif + +rm -f ${RPM_BUILD_ROOT}%{_datadir}/%{name}/gettext.jar + +# own this directory for third-party *.its files +mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}/its + +# remove .la files +rm ${RPM_BUILD_ROOT}%{_libdir}/lib*.la + +# remove internal .so lib files +rm ${RPM_BUILD_ROOT}%{_libdir}/libgettext{src,lib}.so + +# move po-mode initialization elisp file to the right place, and remove byte +# compiled file +install -d ${RPM_BUILD_ROOT}%{_emacs_sitestartdir} +mv ${RPM_BUILD_ROOT}%{_emacs_sitelispdir}/%{name}/start-po.el ${RPM_BUILD_ROOT}%{_emacs_sitestartdir} +rm ${RPM_BUILD_ROOT}%{_emacs_sitelispdir}/%{name}/start-po.elc + +%find_lang %{name}-runtime +%find_lang %{name}-tools +cat %{name}-*.lang > %{name}.lang + +# cleanup rpaths +for i in $RPM_BUILD_ROOT%{_bindir}/* `find $RPM_BUILD_ROOT%{_libdir} -type f`; do + if file $i | grep "ELF 64-bit" >/dev/null; then + chrpath -l $i && chrpath --delete $i + fi +done + + +%if %{with check} +%check +# this takes quite a lot of time to run + +# override LIBUNISTRING to prevent reordering of lib objects +make check LIBUNISTRING=-lunistring +%endif + +%post +/sbin/install-info %{_infodir}/gettext.info.gz %{_infodir}/dir || : + +%preun +if [ "$1" = 0 ]; then + /sbin/install-info --delete %{_infodir}/gettext.info.gz %{_infodir}/dir || : +fi + +%post devel +/sbin/install-info %{_infodir}/autosprintf.info %{_infodir}/dir || : + +%preun devel +if [ "$1" = 0 ]; then + /sbin/install-info --delete %{_infodir}/autosprintf.info %{_infodir}/dir || : +fi + +%ldconfig_scriptlets libs + +%files -f %{name}.lang +%doc AUTHORS gettext-runtime/BUGS +%doc COPYING gettext-tools/misc/DISCLAIM README +%doc NEWS THANKS +%doc gettext-runtime/man/*.1.html +%doc gettext-runtime/intl/COPYING* +%{_bindir}/* +%exclude %{_bindir}/autopoint +%exclude %{_bindir}/gettextize +%exclude %{_bindir}/msghack +%{_infodir}/gettext* +%exclude %{_mandir}/man1/autopoint.1* +%exclude %{_mandir}/man1/msghack.1* +%{_mandir}/man1/* +%{_libdir}/%{name} +%if %{with java} +%exclude %{_libdir}/%{name}/gnu.gettext.* +%endif +%dir %{_datadir}/%{name} +%dir %{_datadir}/%{name}/its +%{_datadir}/%{name}/ABOUT-NLS +%{_datadir}/%{name}/po +%{_datadir}/%{name}/styles +%dir %{_datadir}/%{name}-%{archiveversion} +%{_datadir}/%{name}-%{archiveversion}/its + +%files common-devel +%{_datadir}/%{name}/archive.*.tar.xz + +%files devel +%doc gettext-runtime/man/*.3.html ChangeLog +%{_bindir}/autopoint +%{_bindir}/gettextize +%{_datadir}/%{name}/projects/ +%{_datadir}/%{name}/config.rpath +%{_datadir}/%{name}/*.h +%{_datadir}/%{name}/msgunfmt.tcl +%{_datadir}/aclocal/* +%{_includedir}/* +%{_infodir}/autosprintf* +%{_libdir}/libasprintf.so +%{_libdir}/libgettextpo.so +%{_libdir}/preloadable_libintl.so +%{_mandir}/man1/autopoint.1* +%{_mandir}/man3/* +%{_datadir}/%{name}/intl +%{_datadir}/%{name}/javaversion.class +%doc gettext-runtime/intl-java/javadoc* +%if %{with java} +%{_libdir}/%{name}/gnu.gettext.* +%endif + +%files libs +%{_libdir}/libasprintf.so.0* +%{_libdir}/libgettextpo.so.0* +%{_libdir}/libgettextlib-0.*.so +%{_libdir}/libgettextsrc-0.*.so +%if %{with jar} +%{_datadir}/%{name}/libintl.jar +%endif + +%files -n emacs-%{name} +%dir %{_emacs_sitelispdir}/%{name} +%{_emacs_sitelispdir}/%{name}/*.elc +%{_emacs_sitelispdir}/%{name}/*.el +%{_emacs_sitestartdir}/*.el + +%files -n msghack +%license COPYING +%{_bindir}/msghack +%{_mandir}/man1/msghack.1* + +%changelog +* Fri Jun 14 2019 Sundeep Anand - 0.19.8.1-17 +- Ported CI gating tests to Python 3.6 + +* Fri Jun 14 2019 Sundeep Anand - 0.19.8.1-16 +- add CI gating tests + +* Fri May 3 2019 Jens Petersen - 0.19.8.1-15 +- fix CVE-2018-18751: double-free in xgettext (rhbz#1647049) + +* Wed Feb 07 2018 Fedora Release Engineering - 0.19.8.1-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Sat Feb 03 2018 Igor Gnatenko - 0.19.8.1-13 +- Switch to %%ldconfig_scriptlets + +* Fri Jan 05 2018 Pavel Raiskup - 0.19.8.1-12 +- xgettext --its segfault fix (rhbz#1531476) + +* Wed Aug 02 2017 Fedora Release Engineering - 0.19.8.1-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 0.19.8.1-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Wed Mar 15 2017 Kalev Lember - 0.19.8.1-9 +- Depend on the exact version of the library sub package + +* Fri Feb 10 2017 Fedora Release Engineering - 0.19.8.1-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Jan 26 2017 Pavel Raiskup - 0.19.8.1-7 +- really remove Requires: git from gettext-devel (rhbz#1161284) +- make the BuildRequires unconditional (rhbz#1416691) + +* Wed Dec 21 2016 Pavel Raiskup - 0.19.8.1-6 +- disable test-lock for 'gettext-tool' subdir too (rhbz#1406031) + +* Mon Dec 19 2016 Miro Hrončok - 0.19.8.1-5 +- Rebuild for Python 3.6 + +* Fri Dec 16 2016 Petr Šabata - 0.19.8.1-4 +- Subpackage msghack so that gettext doesn't depend on python +- name the new sub-package 'msghack' + +* Tue Nov 29 2016 Pavel Raiskup - 0.19.8.1-3 +- devel subpackage to Require 'xz' (rhbz#1399270) + +* Wed Aug 10 2016 Daiki Ueno - 0.19.8.1-2 +- utilize %%autosetup +- apply patch to fix po-send-mail when used with Emacs 25 (#1356642) + +* Sat Jun 11 2016 Daiki Ueno - 0.19.8.1-1 +- update to 0.19.8.1 release + +* Thu Jun 9 2016 Daiki Ueno - 0.19.8-1 +- update to 0.19.8 release + +* Wed Feb 03 2016 Fedora Release Engineering - 0.19.7-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Tue Jan 12 2016 Daiki Ueno - 0.19.7-3 +- own .../gettext/its for third-party *.its files +- add a work around for test-isinf failure on ppc64le (#1297387) + +* Fri Jan 8 2016 Daiki Ueno - 0.19.7-2 +- apply patch to recognize .glade extension for GtkBuilder files (#1296653) + +* Thu Dec 10 2015 Daiki Ueno - 0.19.7-1 +- update to 0.19.7 release + +* Thu Sep 24 2015 Daiki Ueno - 0.19.6-1 +- update to 0.19.6 release + +* Wed Jul 22 2015 Daiki Ueno - 0.19.5.1-2 +- work around version conflict between gettextize and autopoint + +* Thu Jul 16 2015 Daiki Ueno - 0.19.5.1-1 +- update to 0.19.5.1 release + +* Fri Jun 26 2015 Daiki Ueno - 0.19.4-7 +- drop -el subpackage (#1234583) + +* Wed Jun 17 2015 Fedora Release Engineering - 0.19.4-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sat May 02 2015 Kalev Lember - 0.19.4-5 +- Rebuilt for GCC 5 C++11 ABI change + +* Sat Feb 21 2015 Till Maas - 0.19.4-4 +- Rebuilt for Fedora 23 Change + https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code + +* Thu Feb 19 2015 Daiki Ueno - 0.19.4-3 +- port msghack.py to Python 3 (#1192086) + +* Wed Dec 31 2014 Daiki Ueno - 0.19.4-2 +- remove git dependency from -devel subpackage (#1161284) + +* Fri Dec 26 2014 Daiki Ueno - 0.19.4-1 +- update to 0.19.4 release + +* Tue Oct 28 2014 Peter Robinson 0.19.3-2 +- Disable the test_lock test as it often hangs on a number of arches + +* Thu Oct 16 2014 Daiki Ueno - 0.19.3-1 +- update to 0.19.3 release +- remove patches included in 0.19.3 +- remove autoconf/automake/libtool/bison from BR, as we don't do bootstrap + +* Wed Oct 15 2014 Daiki Ueno - 0.19.2-5 +- apply patch to fix infloop in autopoint (Closes: #1151238) +- apply patch to support newer ncurses in F-22 + +* Fri Oct 3 2014 Daiki Ueno - 0.19.2-4 +- apply patch to fix C octal character escape handling (Closes: #1147535) + +* Tue Sep 02 2014 Dennis Gilmore - 0.19.2-3 +- rebuild for libunistring soname bump + +* Sat Aug 16 2014 Fedora Release Engineering - 0.19.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Mon Jul 14 2014 Daiki Ueno - 0.19.2-1 +- update to 0.19.2 release + +* Mon Jul 7 2014 Daiki Ueno - 0.19.1-2 +- apply patch to msghack.py, for Python 3 compatibility (Closes: #1113425, + thanks to Bohuslav "Slavek" Kabrda) + +* Tue Jun 10 2014 Daiki Ueno - 0.19.1-1 +- update to 0.19.1 release +- switch to xz-compressed archive + +* Sat Jun 07 2014 Fedora Release Engineering - 0.19-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Mon Jun 2 2014 Daiki Ueno - 0.19-2 +- apply patch to workaround msgfmt bug that counts warnings as errors + +* Mon Jun 2 2014 Daiki Ueno - 0.19-1 +- update to 0.19 release +- remove upstreamed -Wformat-security patch + +* Tue Jan 7 2014 Daiki Ueno - 0.18.3.2-1 +- update to 0.18.3.2 release +- apply patch to suppress -Wformat-security warnings in gnulib-tests + +* Sun Aug 25 2013 Daiki Ueno - 0.18.3.1-1 +- update to 0.18.3.1 release + +* Sat Aug 03 2013 Fedora Release Engineering - 0.18.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Jul 10 2013 Daiki Ueno - 0.18.3-1 +- update to 0.18.3 release + +* Wed Jun 26 2013 Daiki Ueno - 0.18.2.1-2 +- add a man page for msghack +- fix bogus date in %%changelog + +* Tue Mar 12 2013 Daiki Ueno - 0.18.2.1-1 +- update to 0.18.2.1 release (not really necessary though) + +* Wed Feb 13 2013 Fedora Release Engineering - 0.18.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Dec 26 2012 Daiki Ueno - 0.18.2-1 +- update to 0.18.2 release (based on the spec patch by Jens Petersen) + +* Tue Oct 2 2012 Jens Petersen - 0.18.1.1-17 +- move gettextize to the devel subpackage with its source data files +- update msghack to GPL v3 + +* Fri Jul 27 2012 Jens Petersen - 0.18.1.1-16 +- patch gnulib since glibc and C11 dropped gets + +* Thu Jul 19 2012 Fedora Release Engineering - 0.18.1.1-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Tue May 29 2012 Remi Collet - 0.18.1.1-14 +- add upstream patch from debian to fix xgettext segfault in + remember_a_message_plural (#826138) + +* Thu May 17 2012 Jens Petersen - 0.18.1.1-13 +- base package now provides bundled(gnulib) to make it clear that + gettext is built with bundled gnulib (#821757) + +* Wed Jan 25 2012 Harald Hoyer 0.18.1.1-12 +- add filesystem guard + +* Wed Jan 25 2012 Harald Hoyer 0.18.1.1-11 +- install everything in /usr + https://fedoraproject.org/wiki/Features/UsrMove + +* Tue Jan 10 2012 Nils Philippsen - 0.18.1.1-10 +- rebuild for gcc 4.7 + +* Tue Oct 4 2011 Jens Petersen - 0.18.1.1-9 +- correct the configure --with-pic option syntax (Gilles Espinasse) + +* Wed Sep 28 2011 Jens Petersen - 0.18.1.1-8 +- add gettext-readlink-einval.patch to fix build on kernel >= 2.6.39 (#739188) +- add optional buildrequires suggested in the DEPENDENCIES file + +* Tue Feb 08 2011 Fedora Release Engineering - 0.18.1.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Feb 7 2011 Jens Petersen - 0.18.1.1-6 +- remove internal libgettextlib.so and libgettextsrc.so (#650471) + +* Mon Feb 7 2011 Jens Petersen - 0.18.1.1-5 +- fix license field of gettext-libs since libgettextpo is GPLv3+ (#640158) + +* Thu Sep 9 2010 Jens Petersen - 0.18.1.1-4 +- subpackage archive.git.tar.gz to avoid multilib conflicts (#631733) +- update msghack.py header + +* Mon Aug 23 2010 Jens Petersen - 0.18.1.1-3 +- merge autopoint subpackage into devel to simplify deps (#625325) +- have ABOUT-NLS only in the base package datadir + +* Wed Jun 23 2010 Jens Petersen - 0.18.1.1-2 +- correct license tag from GPLv3 to GPLv3+ +- subpackage autopoint which requires git (#574031) +- no longer require cvs (#606746) +- add bcond for git + +* Fri May 21 2010 Jens Petersen - 0.18.1.1-1 +- update to 0.18.1.1 release (#591044) +- gettext-0.17-autopoint-CVS-441481.patch, gettext-0.17-long-long-int-m4.patch + gettext-0.17-open-args.patch, and + gettext-xgettext-python-unicode-surrogate-473946.patch are upstream +- move libintl.jar to lib subpackage to avoid multilib problems + (reported by Jim Radford in #595922) +- disable java for now +- use chrpath to get us out of rpath hell instead of complicated libtool hacks +- enable git support + +* Fri Apr 23 2010 Jens Petersen - 0.17-17 +- create emacs subpackages for po-mode.el (thanks for patch from + Jonathan Underwood, #579452) +- provide emacs-po-mode +- move libgettextlib and libgettextsrc from base to libs subpackage + (requested by Peter Robinson for blender, #579388) + +* Fri Nov 27 2009 Jens Petersen - 0.17-16 +- fix FTBFS by removing openmp.m4 which conflicts with recent autoconf (#539211) +- cleanup gettext-0.17-rpathFix.patch + - separate gl_AC_TYPE_LONG_LONG replacement to another patch + - use trailing ':' for tests LD_LIBRARY_PATH +- run autogen.sh with --quick and --skip-gnulib + +* Tue Sep 1 2009 Jens Petersen - 0.17-15 +- bring back autopoint requires cvs (#517361) +- requires info rather than /sbin/install-info +- drop install_info and remove_install_info macros + +* Fri Jul 24 2009 Fedora Release Engineering - 0.17-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Wed Jun 24 2009 Jens Petersen - 0.17-13 +- buildrequire automake (#507275) +- run autogen + +* Mon Jun 22 2009 Jens Petersen - 0.17-12 +- move intl/ and po/ to base package for gettextize + (reported by Serge Pavlovsky, #496902) + +* Fri May 22 2009 Jens Petersen - 0.17-11 +- use bcond's for build switches + +* Tue Feb 24 2009 Fedora Release Engineering - 0.17-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Feb 12 2009 Jens Petersen - 0.17-9 +- add buildjava switch to allow turning off the java bits completely +- add buildcheck to allow turning off make check +- drop cvs requires for autopoint (Karl Lattimer, #469555) +- add upstream gettext-xgettext-python-unicode-surrogate-473946.patch by + Bruno Haible to fix xgettext handling of utf16 surrogates in python (#473946) + +* Fri Aug 29 2008 Ding-Yi Chen - 0.17-8 +- Fix the build failure with koji. + +* Fri Aug 29 2008 Ding-Yi Chen - 0.17-7 +- Remove the gettext-libs docs, as they are talking about autoconf, libtool, + which are not directly related to the gettext-libs. +- Remove unused definition and trailing space. +- Fix the build failure with mock . + +* Tue Aug 19 2008 Ding-Yi Chen - 0.17-6 +- Fixed Bug 456666 msghack doesn't check for mandatory cmd line params + by adding checking statements and display usage (msghack.py modified) +- rpath patch for binary-or-shlib-defines-rpath in x86_64. + +* Thu Apr 24 2008 Jens Petersen - 0.17-5 +- fix autopoint messing up CVS files with upstream patch (#441481) + +* Mon Feb 18 2008 Jens Petersen - 0.17-4 +- if %%buildjar is off make sure libintl.jar does not get installed (#433210) + +* Mon Feb 18 2008 Jens Petersen - 0.17-3 +- turn on building of libintl.jar now that we have gcc43 + +* Thu Feb 14 2008 Jens Petersen - 0.17-2 +- rebuild with gcc43 + +* Thu Jan 24 2008 Jens Petersen - 0.17-1 +- update to 0.17 release + - update License field to GPLv3 + - add gettext-0.17-open-args.patch to fix build from upstream + - gettext-tools-tests-lang-gawk-fail.patch, gettext-php-headers.patch, + gettext-php-prinf-output-237241.patch, and + gettext-xglade-define-xml-major-version-285701.patch are no longer needed +- drop superfluous po-mode-init.el source +- no need to run autoconf and autoheader when building +- pass -findirect-dispatch to gcj to make java binaries ABI independent + (jakub,#427796) +- move autopoint, gettextize, and {_datadir}/{name}/ to main package +- force removal of emacs/ so install does not fail when no emacs + +* Fri Sep 21 2007 Jens Petersen - 0.16.1-12 +- add a libs subpackage (suggested by Dwayne Bailey, #294891) +- move preloadable_libintl.so to the devel subpackage + +* Fri Sep 14 2007 Nils Philippsen - 0.16.1-11 +- remove gettext-xglade-include-expat-285701.patch, add + gettext-xglade-define-xml-major-version-285701.patch to determine + XML_MAJOR_VERSION from expat.h and define it in config.h (#285701) + +* Wed Sep 12 2007 Jens Petersen - 0.16.1-10 +- buildrequire expat-devel +- add gettext-xglade-include-expat-285701.patch to include expat.h + to get xgettext to dl the right libexpat (Nils Philippsen, #285701) + +* Thu Aug 16 2007 Jens Petersen +- specify license is GPL and LGPL version 2 or later + +* Wed Aug 1 2007 Jens Petersen - 0.16.1-9 +- fix encoding of msghack script (Dwayne Bailey, #250248) + +* Mon Apr 30 2007 Jens Petersen - 0.16.1-8 +- add gettext-php-prinf-output-237241.patch to workaround php test failure + (#237241) +- add gettext-php-headers.patch to correct php test headers + (Robert Scheck, #232832) + +* Thu Mar 15 2007 Jens Petersen - 0.16.1-7 +- set preloadable_libintl.so executable in %%install so it gets stripped +- force removal of infodir/dir since it is not there when /sbin is not in path + +* Tue Mar 13 2007 Jens Petersen - 0.16.1-6 +- add buildjar switch for building of libintl.jar +- lots of spec file cleanup (Mamoru Tasaka, #225791): +- preserve timestamps of installed files +- disable building of static library +- use %%find_lang for .mo files +- remove examples from -devel package +- do not own en@*quot locale dirs +- set preloadable_libintl.so executable +- add ChangeLog to -devel package +- add %%check to run make check +- add gettext-tools-tests-lang-gawk-fail.patch to work around gawk test failure + +* Fri Feb 23 2007 Karsten Hopp 0.16.1-5 +- rebuild to pick up dependency on libgcj.so.8rh instead libgcj.so.7rh + +* Thu Feb 1 2007 Jens Petersen - 0.16.1-4 +- protect install-info in devel %%post and %%preun too (Ville Skyttä, #223689) +- forward port fix to reset of timestamp of examples ChangeLog for + brp-java-repack-jars libintl.jar multilib conflict (#205207) + +* Mon Jan 22 2007 Jens Petersen - 0.16.1-3 +- protect install-info in %%post and %%preun (Ville Skyttä, #223689) + +* Fri Dec 22 2006 Jens Petersen - 0.16.1-1 +- update to 0.16.1 + +* Mon Nov 27 2006 Jens Petersen - 0.16-2 +- re-enable openmp on ia64 + +* Thu Nov 23 2006 Jens Petersen - 0.16-1 +- update to 0.16 release +- disable openmp on ia64 (#216988) + +* Fri Oct 27 2006 Jens Petersen - 0.15-1 +- update to 0.15 release +- mkinstalldirs and libintl.jar are gone +- javaversion.class added + +* Mon Oct 2 2006 Jens Petersen - 0.14.6-3 +- buildrequire zip and unzip to fix libintl.jar multilib conflict (#205207) + +* Fri Aug 25 2006 Jens Petersen - 0.14.6-2 +- move libgettext*.so devel files to devel package (Patrice Dumas, #203622) + +* Mon Aug 7 2006 Jens Petersen - 0.14.6-1 +- update to 0.14.6 +- include preloadable_libintl.so again (Roozbeh Pournader, #149809) +- remove .la files (Kjartan Maraas, #172624) +- cleanup spec file + +* Tue Jul 25 2006 Thomas Fitzsimmons - 0.14.5-4 +- Bump release number. + +* Wed Jul 12 2006 Jesse Keating - 0.14.5-3.1 +- rebuild + +* Wed Feb 22 2006 Karsten Hopp 0.14.5-3 +- --disable-csharp, otherwise it'll build a dll when mono is + installed in the buildroot. + +* Fri Feb 10 2006 Jesse Keating - 0.14.5-2.2.2 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 0.14.5-2.2.1 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Tue Jan 3 2006 Jesse Keating 0.14.5-2.2 +- rebuilt again + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Wed Sep 28 2005 Jindrich Novy 0.14.5-2 +- convert spec to UTF-8 +- remove old tarballs from sources + +* Thu Aug 11 2005 Leon Ho +- updated to 0.14.5 +- Add cvs as Requires for gettext-devel + +* Mon Mar 21 2005 Leon Ho +- updated to 0.14.3 +- fixed compiling problem on gcc4 (#150992) +- fixed Group for -devel (#138303) +- moved gettextize and autopoint to -devel (#137542, #145768) +- moved some of the man pages + +* Tue Mar 01 2005 Jakub Jelinek +- rebuilt with gcc 4.0 + +* Wed Dec 01 2004 Leon Ho +- Add env var to redirect use fastjar instead of jar +- BuildRequires fastjar and libgcj + +* Mon Nov 01 2004 Leon Ho +- fix call on phase0_getc() +- fix temp file issue (#136323 - CAN-2004-0966 - mjc) + +* Sun Oct 03 2004 Leon Ho +- fixed typo on %%preun on -devel + +* Fri Oct 01 2004 Leon Ho +- fix install_info +- add gcc-java build requirement + +* Mon Sep 13 2004 Leon Ho +- move java stuff to gettext-devel (#132239) +- add BuildRequires: gcc-c++ (#132518) +- add some missing install-info and ldconfig (#131272) +- fix dir ownership (#133696) +- run autotools for 1.9 + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Tue Jun 08 2004 Leon Ho +- use --without-included-gettext to avoid the need of libintl.so (#125497) +- remove preloadable_libintl.so + +* Sun Jun 06 2004 Leon Ho +- moved some of the shared lib to main pkg +- added more build requires + +* Thu Jun 03 2004 Leon Ho +- add conditionals for patch and requires auto* (#125216) + +* Wed Jun 02 2004 Leon Ho +- packaged lib files for devel +- moved some of the files to different sub-pkg +- fix problem on x86_64 build + +* Tue Mar 02 2004 Elliot Lee +- rebuilt + +* Fri Feb 13 2004 Elliot Lee +- rebuilt + +* Mon Feb 02 2004 Leon Ho +- rebuilt to 0.14.1 + +* Fri Sep 19 2003 Leon Ho +- rebuilt 0.12.1 +- fix including files and excludes some patches + +* Wed Jun 04 2003 Elliot Lee +- rebuilt + +* Wed May 14 2003 Leon Ho +- 0.11.5 + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Thu Jan 16 2003 Leon Ho 0.11.4-6 +- add online help for msghack replacement + +* Thu Dec 5 2002 Leon Ho 0.11.4-5 +- add patch to fix gettextize (#78720) + +* Wed Nov 27 2002 Tim Powers 0.11.4-4 +- remove unpackaged files from the buildroot + +* Wed Aug 28 2002 Trond Eivind Glomsrød 0.11.4-3 +- Use %%{_libdir} instead of /usr/lib (#72524) + +* Fri Aug 2 2002 Nalin Dahyabhai 0.11.4-2 +- install ulonglong.m4, which is required by uintmax_t.m4, which is already + being installed + +* Sun Jul 28 2002 Trond Eivind Glomsrød 0.11.4-1 +- 0.11.4 + +* Fri Jun 21 2002 Tim Powers +- automated rebuild + +* Thu May 23 2002 Tim Powers +- automated rebuild + +* Tue May 14 2002 Trond Eivind Glomsrød 0.11.2-1 +- 0.11.2 +- include some new files + +* Fri Apr 5 2002 Trond Eivind Glomsrød 0.11.1-2 +- Add patch to make it compile with C99 compilers (#62313) + +* Wed Mar 13 2002 Trond Eivind Glomsrød 0.11.1-1 +- 0.11.1 + +* Sun Feb 17 2002 Florian La Roche +- update gettext to 0.11 +- disable patch4 + +* Wed Jan 09 2002 Tim Powers +- automated rebuild + +* Wed Dec 5 2001 Trond Eivind Glomsrød 0.10.40-3 +- improve automake handling + +* Wed Nov 14 2001 Trond Eivind Glomsrød 0.10.40-2 +- Add URL +- Add automake workaround (#56081) + +* Sun Sep 16 2001 Trond Eivind Glomsrød 0.10.40-1 +- 0.10.40 - libintl is now LGPLed (it was GPLed). Note that RHL + uses the glibc version, and don't include libintl from gettext. +- include new man pages +- don't include the elisp mode - bundle it into the main emacs package, + like we do for XEmacs. +- README-alpha no longer exists, so don't list it as a doc file + +* Fri Aug 24 2001 Trond Eivind Glomsrød 0.10.38-7 +- Rebuild - this should fix #52463 + +* Wed Aug 22 2001 Trond Eivind Glomsrød 0.10.38-6 +- Fix handling of multiline entries (rest of #50065) +- don't use the references of the last entry in a po file +- remove duplicates when inverting +- Own the en@quot and en@boldquot locale dirs (#52164) +- Handle entries with a first line of "" as identical to those + without + +* Thu Aug 9 2001 Trond Eivind Glomsrød +- Added "--append" and "-o" to msghack, which should address + initial concerns in #50065 + +* Thu Jul 19 2001 Trond Eivind Glomsrød +- New msghack - from scratch, in python + +* Tue Jul 17 2001 Trond Eivind Glomsrød +- msghack is back + +* Mon Jun 4 2001 Trond Eivind Glomsrød +- Include some docfiles + +* Sun Jun 03 2001 Florian La Roche +- 0.10.38 +- do not include charset.alias + +* Wed May 2 2001 Nalin Dahyabhai +- Build statically. + +* Mon Apr 30 2001 Trond Eivind Glomsrød +- 0.10.37 +- Disable all but two patches + +* Sun Feb 25 2001 Trond Eivind Glomsrød +- Initialize proper fonts when entering po-mode (#29152) + +* Mon Feb 12 2001 Yukihiro Nakai +- More fix about msgmerge. + +* Mon Feb 12 2001 Yukihiro Nakai +- Fix for msgmerge not to break multibyte strings + at Japanese locale. + +* Wed Jan 24 2001 Matt Wilson +- fixed the %%lang generator to not have "./" in the lang + +* Sun Jan 14 2001 Trond Eivind Glomsrød +- add an init file for the emacs po-mode +- update source URL + +* Thu Jan 11 2001 Bill Nottingham +- put gettext in /bin for initscripts use +- %%langify + +* Fri Dec 29 2000 Bill Nottingham +- prereq /sbin/install-info + +* Wed Aug 23 2000 Trond Eivind Glomsrød +- Added patch from Ulrich Drepper + +* Fri Aug 04 2000 Trond Eivind Glomsrød +- update DESTDIR patch (#12072) + +* Thu Jul 13 2000 Prospector +- automatic rebuild + +* Mon Jul 10 2000 Trond Eivind Glomsrød +- fix problems wrt to DESTDIR (#12072) + +* Thu Jun 22 2000 Preston Brown +- use FHS paths +- add buildroot patch for .../intl/Makefile.in, was using abs. install path + +* Fri Apr 28 2000 Bill Nottingham +- minor configure tweaks for ia64 + +* Sun Feb 27 2000 Cristian Gafton +- add --comments to msghack + +* Thu Feb 10 2000 Cristian Gafton +- fix bug #9240 - gettextize has the right aclocal patch + +* Wed Jan 12 2000 Cristian Gafton +- add the --diff and --dummy options + +* Wed Oct 06 1999 Cristian Gafton +- add the --missing option to msghack + +* Wed Sep 22 1999 Cristian Gafton +- updated msghack not to merge in fuzzies in the master catalogs + +* Thu Aug 26 1999 Cristian Gafton +- updated msghack to understand --append + +* Wed Aug 11 1999 Cristian Gafton +- updated msghack to correctly deal with sorting files + +* Thu May 06 1999 Cristian Gafton +- msghack updates + +* Sun Mar 21 1999 Cristian Gafton +- auto rebuild in the new build environment (release 8) + +* Mon Mar 08 1999 Cristian Gafton +- added patch for misc hacks to facilitate rpm translations + +* Thu Dec 03 1998 Cristian Gafton +- patch to allow to build on ARM + +* Wed Sep 30 1998 Jeff Johnson +- add Emacs po-mode.el files. + +* Sun Sep 13 1998 Cristian Gafton +- include the aclocal support files + +* Thu Sep 3 1998 Bill Nottingham +- remove devel package (functionality is in glibc) + +* Tue Sep 1 1998 Jeff Johnson +- update to 0.10.35. + +* Mon Jun 29 1998 Jeff Johnson +- add gettextize. +- create devel package for libintl.a and libgettext.h. + +* Mon Apr 27 1998 Prospector System +- translations modified for de, fr, tr + +* Sun Nov 02 1997 Cristian Gafton +- added info handling +- added misc-patch (skip emacs-lisp modofications) + +* Sat Nov 01 1997 Erik Troan +- removed locale.aliases as we get it from glibc now +- uses a buildroot + +* Mon Jun 02 1997 Erik Troan +- Built against glibc diff --git a/msghack.1 b/msghack.1 new file mode 100644 index 0000000..42fcc5b --- /dev/null +++ b/msghack.1 @@ -0,0 +1,45 @@ +.TH MSGHACK "1" "June 2013" "msghack" "User Commands" +.SH NAME +msghack \- alter PO files in ways +.SH SYNOPSIS +.B msghack +[\fIOPTION\fR] \fIfile.po \fR[\fIref.po\fR] +.SH DESCRIPTION +.PP +This program can be used to alter .po files in ways no sane mind would think about. +.TP +\fB\-o\fR +result will be written to FILE +.TP +\fB\-\-invert\fR +invert a po file by switching msgid and msgstr +.TP +\fB\-\-master\fR +join any number of files in a master\-formatted catalog +.TP +\fB\-\-empty\fR +empty the contents of the .po file, creating a .pot +.TP +\fB\-\-append\fR +append entries from ref.po that don't exist in file.po +.PP +Note: It is just a replacement of msghack for backward support. +.PP +This program can be used to alter .po files in ways no sane mind would think about. +.TP +\fB\-o\fR +result will be written to FILE +.TP +\fB\-\-invert\fR +invert a po file by switching msgid and msgstr +.TP +\fB\-\-master\fR +join any number of files in a master\-formatted catalog +.TP +\fB\-\-empty\fR +empty the contents of the .po file, creating a .pot +.TP +\fB\-\-append\fR +append entries from ref.po that don't exist in file.po +.PP +Note: It is just a replacement of msghack for backward support. diff --git a/msghack.py b/msghack.py new file mode 100755 index 0000000..358552c --- /dev/null +++ b/msghack.py @@ -0,0 +1,417 @@ +#!/usr/bin/python3 +## -*- coding: utf-8 -*- +## Copyright (C) 2001, 2004, 2008, 2012 Red Hat, Inc. +## Copyright (C) 2001 Trond Eivind Glomsrød + +## 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 +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . + +""" +A msghack replacement +""" + +import sys + +class GTMessage: + """ + A class containing a message, its msgid and various references pointing at it + """ + + def __init__(self,id=None,message=None,refs=[]): + """ + The constructor for the GTMessage class + @self The object instance + @message The message + @id The messageid associated with the object + """ + self._message=message.strip() + self._id=id.strip() + self._refs=[] + for ref in refs: + self._refs.append(ref) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + res=res+"msgid %s\nmsgstr %s\n" % (self._id,self._message) + return res + + def invertedStrings(self): + """ + Returns a string representation, but with msgid and msgstr inverted. + Note: Don't invert the "" string + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + if not self._id=="\"\"": + res=res+"msgid %s\nmsgstr %s\n" % (self._message,self._id) + else: + res=res+"msgid %s\nmsgstr %s\n" % (self._id,self._message) + return res + + def emptyMsgStrings(self): + """ + Return a string representation of the object, but leave the msgstr + empty - create a pot file from a po file + Note: Won't remove the "" string + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + if not self._id=="\"\"": + res=res+"msgid %s\nmsgstr \"\"\n" % (self._id) + else: + res=res+"msgid %s\nmsgstr %s\n" % (self._id,self._message) + return res + + def compareMessage(self,msg): + """ + Return if the messages have identical msgids, 0 otherwise + @self The object instance + @msg The message to compare to + """ + + if self._id == msg._id: + return 1 + return 0 + + +class GTMasterMessage: + """ + A class containing a message, its msgid and various references pointing at it + The difference between GTMessage and GTMasterMessage is that this class + can do less operations, but is able to store multiple msgstrs with identifiers + (usually language, like 'msgst(no)' + """ + + def __init__(self,id=None,refs=[]): + """ + The constructor for the GTMessage class + @self The object instance + @id The messageid associated with the object + """ + self._id=id + self._refs=[] + self._messages=[] + for ref in refs: + self._refs.append(ref) + + def addMessage(self,message,identifier): + """ + Add a new message and identifier to the GTMasterMessage object + @self The object instance + @message The message to append + @identifier The identifier of the message + """ + self._messages.append((identifier,message)) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + res=res+"msgid %s\n" % self._id + for message in self._messages: + res=res+"msgstr(%s) %s\n" %(message[0],message[1]) + res=res+"\n" + return res + +class GTFile: + """ + A class containing the GTMessages contained in a file + """ + + def __init__(self,filename): + """ + The constructor of the GTMFile class + @self The object instance + @filename The file to initialize from + """ + self._filename=filename + self._messages=[] + self.readFile(filename) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for message in self._messages: + res=res+str(message)+"\n" + return res + + def invertedStrings(self): + """ + Return a string representation of the object, with msgid and msgstr + swapped. Will remove duplicates... + @self The object instance + """ + + msght={} + msgar=[] + + for message in self._messages: + if message._id=='""' and len(msgar)==0: + msgar.append(GTMessage(message._id,message._message,message._refs)) + continue + msg=GTMessage(message._message,message._id,message._refs) + if msg._id not in msght: + msght[msg._id]=msg + msgar.append(msg) + else: + msg2=msght[msg._id] + for ref in msg._refs: + msg2._refs.append(ref) + res="" + for message in msgar: + res=res+str(message)+"\n" + return res + + def msgidDupes(self): + """ + Search for duplicates in the msgids. + @self The object instance + """ + msgids={} + res="" + for message in self._messages: + msgid=message._id + if msgid in msgids: + res=res+"Duplicate: %s\n" % (msgid) + else: + msgids[msgid]=1 + return res + + def getMsgstr(self,msgid): + """ + Return the msgstr matching the given id. 'None' if missing + @self The object instance + @msgid The msgid key + """ + + for message in self._messages: + if msgid == message._id: + return message._message + return None + + def emptyMsgStrings(self): + """ + Return a string representation of the object, but leave the msgstr + empty - create a pot file from a po file + @self The object instance + """ + + res="" + for message in self._messages: + res=res+message.emptyMsgStrings()+"\n" + return res + + + def append(self,B): + """ + Append entries from dictionary B which aren't + already present in this dictionary + @self The object instance + @B the dictionary to append messages from + """ + + for message in B._messages: + if not self.getMsgstr(message._id): + self._messages.append(message) + + + def readFile(self,filename): + """ + Read the contents of a file into the GTFile object + @self The object instance + @filename The name of the file to read + """ + + file=open(filename,"r") + msgid="" + msgstr="" + refs=[] + lines=[] + inmsgid=0 + inmsgstr=0 + templines=file.readlines() + for line in templines: + lines.append(line.strip()) + for line in lines: + pos=line.find('"') + pos2=line.rfind('"') + if line and line[0]=="#": + refs.append(line.strip()) + if inmsgstr==0 and line[:6]=="msgstr": + msgstr="" + inmsgstr=1 + inmsgid=0 + if inmsgstr==1: + if pos==-1: + inmsgstr=0 + #Handle entries with and without "" consistently + if msgid[:2]=='""' and len(msgid)>4: + msgid=msgid[2:] + if msgstr[:2]=='""' and len(msgstr)>4: + msgstr=msgstr[2:] + message=GTMessage(msgid,msgstr,refs) + self._messages.append(message) + msgstr="" + msgid="" + refs=[] + else: + msgstr=msgstr+line[pos:pos2+1]+"\n" + if inmsgid==0 and line[:5]=="msgid": + msgid="" + inmsgid=1 + if inmsgid==1: + if pos==-1: + inmsgid=0 + else: + msgid=msgid+line[pos:pos2+1]+"\n" + if msgstr and msgid: + message=GTMessage(msgid,msgstr,refs) + self._messages.append(message) + + +class GTMaster: + """ + A class containing a master catalogue of gettext dictionaries + """ + + def __init__(self,dicts): + """ + The constructor for the GTMaster class + @self The object instance + @dicts An array of dictionaries to merge + """ + self._messages=[] + self.createMaster(dicts) + + def createMaster(self,dicts): + """ + Create the master catalogue + @self The object instance + @dicts An array of dictionaries to merge + """ + + self._master=dicts[0] + self._dicts=dicts[1:] + + for message in self._master._messages: + gtm=GTMasterMessage(message._id,message._refs) + gtm.addMessage(message._message,self._master._filename[:-3]) + for dict in self._dicts: + res=dict.getMsgstr(message._id) + if(res): + gtm.addMessage(res,dict._filename[:-3]) + self._messages.append(gtm) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for message in self._messages: + res=res+str(message)+"\n" + return res + +def printUsage(): + "Print the usage messages" + print("Usage: " + str(sys.argv[0]) + " [OPTION] file.po [ref.po]\n\ +This program can be used to alter .po files in ways no sane mind would think about.\n\ + -o result will be written to FILE\n\ + --invert invert a po file by switching msgid and msgstr\n\ + --master join any number of files in a master-formatted catalog\n\ + --empty empty the contents of the .po file, creating a .pot\n\ + --append append entries from ref.po that don't exist in file.po\n\ +\n\ +Note: It is just a replacement of msghack for backward support.\n") + + +if __name__=="__main__": + output=None + res=None + if("-o") in sys.argv: + if (len(sys.argv)<=sys.argv.index("-o")+1): + print("file.po and ref.po are not specified!\n") + printUsage() + exit(1) + output=sys.argv[sys.argv.index("-o")+1] + sys.argv.remove("-o") + sys.argv.remove(output) + if("--invert") in sys.argv: + if (len(sys.argv)<=sys.argv.index("--invert")+1): + print("file.po is not specified!\n") + printUsage() + exit(1) + file=sys.argv[sys.argv.index("--invert")+1] + gtf=GTFile(file) + res1=gtf.msgidDupes() + if res1: + sys.stderr.write(res1) + sys.exit(1) + res=str(gtf.invertedStrings()) + elif("--empty") in sys.argv: + if (len(sys.argv)<=sys.argv.index("--empty")+1): + print("file.po is not specified!\n") + printUsage() + exit(1) + file=sys.argv[sys.argv.index("--empty")+1] + gtf=GTFile(file) + res=str(gtf.emptyMsgStrings()) + elif("--master") in sys.argv: + if (len(sys.argv)<=sys.argv.index("--master")+1): + print("file.po is not specified!\n") + printUsage() + exit(1) + loc=sys.argv.index("--master")+1 + gtfs=[] + for file in sys.argv[loc:]: + gtfs.append(GTFile(file)) + master=GTMaster(gtfs) + res=str(master) + elif("--append") in sys.argv: + if (len(sys.argv)<=sys.argv.index("--append")+2): + print("file.po and/or ref.po are not specified!\n") + printUsage() + exit(1) + file=sys.argv[sys.argv.index("--append")+1] + file2=sys.argv[sys.argv.index("--append")+2] + gtf=GTFile(file) + gtf2=GTFile(file2) + gtf.append(gtf2) + res=str(gtf) + else: + #print("Not implemented: "+str(sys.argv)) + printUsage() + sys.exit(1) + if not output: + print(res) + else: + file=open(output,"w") + file.write(res) + sys.exit(0) diff --git a/sources b/sources new file mode 100644 index 0000000..b704130 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (gettext-0.19.8.1.tar.xz) = 3553227b62f2a7d9b67c881ef889c030a6a21d5ecd210c4bf3d649df0b37193a99a68cf8fd5f2c69b6a87e847035dd9576f9bcb9363422866e26b04f4f6dd431