[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gettext patches for cygwin #4: accessing fields of exported structs/arra
From: |
Charles Wilson |
Subject: |
gettext patches for cygwin #4: accessing fields of exported structs/arrays |
Date: |
Sun, 20 Nov 2005 00:04:48 -0500 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Windows/20050716) |
Cygwin is a windows-ish platform, but doesn't #define WIN32. Therefore
we must be sure to access fields of structs indirectly.
2005-11-20 Charles Wilson <address@hidden>
* gettext-tools/src/plural-table.c (get_plural_table_entry):
new accessor function
* gettext-tools/src/plural-table.h (get_plural_table_entry):
ditto
* gettext-tools/src/msgfmt.c (check_plural): use
get_plural_table_entry() accessor instead of plural_table[].
* gettext-tools/src/msginit.c (plural_forms): use
get_plural_table_entry() accessor instead of plural_table[].
* gettext-tools/src/po-lex.c: force using function calls not
macros for po_gram_error and po_gram_error_at_line on cygwin.
* gettext-tools/src/po-lex.h: ditto
--
Chuck
diff -urN gettext-0.14.5-orig/gettext-tools/src/msgfmt.c
gettext-0.14.5/gettext-tools/src/msgfmt.c
--- gettext-0.14.5-orig/gettext-tools/src/msgfmt.c 2005-05-20
16:40:48.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgfmt.c 2005-11-11 00:58:29.921875000
-0500
@@ -1117,14 +1117,14 @@
language += 15;
for (j = 0; j < plural_table_size; j++)
if (strncmp (language,
- plural_table[j].language,
- strlen (plural_table[j].language)) == 0)
+ get_plural_table_entry(j).language,
+ strlen (get_plural_table_entry(j).language)) == 0)
{
char *recommended =
- xasprintf ("Plural-Forms: %s\\n", plural_table[j].value);
+ xasprintf ("Plural-Forms: %s\\n",
get_plural_table_entry(j).value);
fprintf (stderr,
_("Try using the following, valid for %s:\n"),
- plural_table[j].language);
+ get_plural_table_entry(j).language);
fprintf (stderr, "\"%s\"\n", recommended);
free (recommended);
break;
diff -urN gettext-0.14.5-orig/gettext-tools/src/msginit.c
gettext-0.14.5/gettext-tools/src/msginit.c
--- gettext-0.14.5-orig/gettext-tools/src/msginit.c 2005-05-20
16:41:09.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msginit.c 2005-11-11 00:59:01.140625000
-0500
@@ -1374,13 +1374,13 @@
/* Search for a formula depending on the catalogname. */
for (i = 0; i < plural_table_size; i++)
- if (strcmp (plural_table[i].lang, catalogname) == 0)
- return plural_table[i].value;
+ if (strcmp (get_plural_table_entry(i).lang, catalogname) == 0)
+ return get_plural_table_entry(i).value;
/* Search for a formula depending on the language only. */
for (i = 0; i < plural_table_size; i++)
- if (strcmp (plural_table[i].lang, language) == 0)
- return plural_table[i].value;
+ if (strcmp (get_plural_table_entry(i).lang, language) == 0)
+ return get_plural_table_entry(i).value;
return NULL;
}
diff -urN gettext-0.14.5-orig/gettext-tools/src/plural-table.c
gettext-0.14.5/gettext-tools/src/plural-table.c
--- gettext-0.14.5-orig/gettext-tools/src/plural-table.c 2005-05-20
16:42:40.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/plural-table.c 2005-11-11
00:59:27.484375000 -0500
@@ -63,3 +63,10 @@
{ "sl", "Slovenian", "nplurals=4; plural=(n%100==1 ? 0 : n%100==2
? 1 : n%100==3 || n%100==4 ? 2 : 3);" }
};
const size_t plural_table_size = sizeof (plural_table) / sizeof
(plural_table[0]);
+struct plural_table_entry
+get_plural_table_entry(size_t index)
+{
+ if ((index < 0) || (index > plural_table_size))
+ index = 0;
+ return plural_table[index];
+}
diff -urN gettext-0.14.5-orig/gettext-tools/src/plural-table.h
gettext-0.14.5/gettext-tools/src/plural-table.h
--- gettext-0.14.5-orig/gettext-tools/src/plural-table.h 2005-05-20
16:42:43.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/plural-table.h 2005-11-11
00:59:41.562500000 -0500
@@ -30,5 +30,6 @@
extern DLL_VARIABLE struct plural_table_entry plural_table[];
extern DLL_VARIABLE const size_t plural_table_size;
+extern struct plural_table_entry get_plural_table_entry(size_t index);
#endif /* _PLURAL_TABLE_H */
diff -urN gettext-0.14.5-orig/gettext-tools/src/po-lex.c
gettext-0.14.5/gettext-tools/src/po-lex.c
--- gettext-0.14.5-orig/gettext-tools/src/po-lex.c 2005-05-20
16:43:18.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/po-lex.c 2005-11-11 01:00:25.031250000
-0500
@@ -72,7 +72,8 @@
#if !(__STDC__ && \
((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined
__DECC) \
- || (defined __GNUC__ && __GNUC__ >= 2 && !defined __APPLE_CC__)))
+ || (defined __GNUC__ && __GNUC__ >= 2 && \
+ ! (defined __APPLE_CC__ || defined __CYGWIN__ || defined
__MINGW32__ ))))
/* CAUTION: If you change this function, you must also make identical
changes to the macro of the same name in src/po-lex.h */
diff -urN gettext-0.14.5-orig/gettext-tools/src/po-lex.h
gettext-0.14.5/gettext-tools/src/po-lex.h
--- gettext-0.14.5-orig/gettext-tools/src/po-lex.h 2005-05-20
16:43:21.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/po-lex.h 2005-11-11 01:01:18.046875000
-0500
@@ -109,7 +109,10 @@
} while (0)
/* GCC is also smart enough to allow optimizations like this. */
-#elif __STDC__ && defined __GNUC__ && __GNUC__ >= 2 && !defined __APPLE_CC__
+/* But, we can't access member fields of structs that are exported
+ from DLLs on windows, so use the function calls not the macros */
+#elif __STDC__ && defined __GNUC__ && __GNUC__ >= 2 && \
+ !(defined __APPLE_CC__ || defined __CYGWIN__ || defined __MINGW32__)
/* CAUTION: If you change this macro, you must also make identical
changes to the function of the same name in src/po-lex.c */
- gettext patches for cygwin #4: accessing fields of exported structs/arrays,
Charles Wilson <=
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Bruno Haible, 2005/11/21
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Charles Wilson, 2005/11/22
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Bruno Haible, 2005/11/22
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Charles Wilson, 2005/11/23
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Ralf Wildenhues, 2005/11/24
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Bruno Haible, 2005/11/24
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Charles Wilson, 2005/11/24
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Charles Wilson, 2005/11/27
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Bruno Haible, 2005/11/23
- Re: gettext patches for cygwin #4: accessing fields of exported structs/arrays, Charles Wilson, 2005/11/24