From: Bruno Haible Date: Mon, 5 Apr 2010 13:16:08 +0000 (+0200) Subject: Interoperability with mono versions >= 2009-02-27. X-Git-Tag: v0.18~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04315eb6d1c101ac3a6e8a8d6694ee1e8ae59ca5;p=thirdparty%2Fgettext.git Interoperability with mono versions >= 2009-02-27. --- diff --git a/NEWS b/NEWS index b1e99936b..ed9a45786 100644 --- a/NEWS +++ b/NEWS @@ -69,7 +69,9 @@ Version 0.18 - January 2008 locally installed a 3 MB large archive. * Portability: - The msgfilter program now also works on native Woe32 platforms. + - The msgfilter program now also works on native Woe32 platforms. + - Compiled C# message catalogs now also work with 'mono' versions from 2009 + or newer. Version 0.17 - November 2007 diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index cb00dc6ba..b70f43323 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2010-04-05 Bruno Haible + + Interoperability with mono versions >= 2009-02-27. + * write-csharp.c (write_csharp_code): Emit a TableInitialized field. + Change ReadResources so that it may be called multiple times, even + concurrently. + Reported by Guido Flohr + 2010-03-31 Guido Flohr Improve how xgettext handles Perl syntax ambiguities. diff --git a/gettext-tools/src/write-csharp.c b/gettext-tools/src/write-csharp.c index 3e5795690..047361a11 100644 --- a/gettext-tools/src/write-csharp.c +++ b/gettext-tools/src/write-csharp.c @@ -1,5 +1,5 @@ /* Writing C# satellite assemblies. - Copyright (C) 2003-2009 Free Software Foundation, Inc. + Copyright (C) 2003-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -541,22 +541,37 @@ write_csharp_code (FILE *stream, const char *culture_name, const char *class_nam fprintf (stream, " : base () {\n"); fprintf (stream, " }\n"); + /* Emit the TableInitialized field. */ + fprintf (stream, " private bool TableInitialized;\n"); + /* Emit the ReadResources method. */ fprintf (stream, " protected override void ReadResources () {\n"); + /* In some implementations, such as mono < 2009-02-27, the ReadResources + method is called just once, when Table == null. In other implementations, + such as mono >= 2009-02-27, it is called at every GetObject call, and it + is responsible for doing the initialization only once, even when called + simultaneously from multiple threads. */ + fprintf (stream, " if (!TableInitialized) {\n"); + fprintf (stream, " lock (this) {\n"); + fprintf (stream, " if (!TableInitialized) {\n"); /* In some implementations, the ResourceSet constructor initializes Table before calling ReadResources(). In other implementations, the ReadResources() method is expected to initialize the Table. */ - fprintf (stream, " if (Table == null)\n"); - fprintf (stream, " Table = new System.Collections.Hashtable();\n"); - fprintf (stream, " System.Collections.Hashtable t = Table;\n"); + fprintf (stream, " if (Table == null)\n"); + fprintf (stream, " Table = new System.Collections.Hashtable();\n"); + fprintf (stream, " System.Collections.Hashtable t = Table;\n"); for (j = 0; j < mlp->nitems; j++) { - fprintf (stream, " t.Add("); + fprintf (stream, " t.Add("); write_csharp_msgid (stream, mlp->item[j]); fprintf (stream, ","); write_csharp_msgstr (stream, mlp->item[j]); fprintf (stream, ");\n"); } + fprintf (stream, " TableInitialized = true;\n"); + fprintf (stream, " }\n"); + fprintf (stream, " }\n"); + fprintf (stream, " }\n"); fprintf (stream, " }\n"); /* Emit the msgid_plural strings. Only used by msgunfmt. */