]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Interoperability with mono versions >= 2009-02-27.
authorBruno Haible <bruno@clisp.org>
Mon, 5 Apr 2010 13:16:08 +0000 (15:16 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Apr 2010 14:05:49 +0000 (16:05 +0200)
NEWS
gettext-tools/src/ChangeLog
gettext-tools/src/write-csharp.c

diff --git a/NEWS b/NEWS
index b1e99936b768889b3f146472ec6191ac9b8087de..ed9a45786d18acec8e896b4a1bb02634ef164eae 100644 (file)
--- 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.
 \f
 Version 0.17 - November 2007
 
index cb00dc6ba5da6fdc5e5243b8ff99c9032a5bdeee..b70f433237082580441de11369cf6a048501d8ba 100644 (file)
@@ -1,3 +1,11 @@
+2010-04-05  Bruno Haible  <bruno@clisp.org>
+
+       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  <guido@imperia.net>
+
 2010-03-31  Guido Flohr  <guido@imperia.net>
 
        Improve how xgettext handles Perl syntax ambiguities.
index 3e5795690cd657581ff5a1005a8fa73a30fbe353..047361a1158916a011975fdfb493fd06fafc893b 100644 (file)
@@ -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 <bruno@clisp.org>, 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.  */