Author: faridz
Date: Wed Sep 5 02:24:09 2007
New Revision: 572920
URL: http://svn.apache.org/viewvc?rev=572920&view=rev
Log:
2007-09-05 Farid Zaripov <[EMAIL PROTECTED]>
* rw_locale.h (rw_create_catalog): New function to generate message
catalog.
* locale.cpp (rw_create_catalog): Ditto.
Modified:
incubator/stdcxx/trunk/tests/include/rw_locale.h
incubator/stdcxx/trunk/tests/src/locale.cpp
Modified: incubator/stdcxx/trunk/tests/include/rw_locale.h
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/rw_locale.h?rev=572920&r1=572919&r2=572920&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/rw_locale.h (original)
+++ incubator/stdcxx/trunk/tests/include/rw_locale.h Wed Sep 5 02:24:09 2007
@@ -120,4 +120,13 @@
_TEST_EXPORT int
rw_opt_setlocales (int, char*[]);
+
+// creates message file and invokes gencat to create message catalog
+// then removes the message file
+// catalog is a '\0' separated list of strings, each of which representing
+// a single message, and with a blank line separating one set from another
+// returns 0 in success
+_TEST_EXPORT int
+rw_create_catalog (const char * /* catname */, const char * /* catalog */);
+
#endif // RW_LOCALE_H_INCLUDED
Modified: incubator/stdcxx/trunk/tests/src/locale.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/locale.cpp?rev=572920&r1=572919&r2=572920&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/locale.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/locale.cpp Wed Sep 5 02:24:09 2007
@@ -108,6 +108,13 @@
#define RELPATH "etc" SLASH "nls"
#define TESTS_ETC_PATH "tests" SLASH "etc"
+// extension of the catalog file
+#ifndef _WIN32
+# define RW_CAT_EXT ".cat"
+#else
+# define RW_CAT_EXT ".dll"
+#endif
+
/**************************************************************************/
_TEST_EXPORT int
@@ -858,4 +865,55 @@
// return 0 on success
return 0;
+}
+
+
+/**************************************************************************/
+
+_TEST_EXPORT int
+rw_create_catalog (const char * catname, const char * catalog)
+{
+ RW_ASSERT (catname && catalog);
+
+ FILE* const f = fopen (catname, "w");
+
+ if (!f)
+ return -1;
+
+#ifndef _WIN32
+
+ for (int i = 1; *catalog; ++catalog, ++i) {
+ fprintf (f, "$set %d This is Set %d\n", i, i);
+ for (int j = 1; *catalog; catalog += strlen (catalog) + 1, ++j)
+ fprintf (f, "%d %s\n", j, catalog);
+ }
+
+#else // if defined (_WIN32)
+
+ fprintf (f, "STRINGTABLE\nBEGIN\n");
+
+ for (int i = 1; *catalog; ++catalog) {
+ for (; *catalog; catalog += strlen (catalog) + 1, ++i)
+ fprintf (f, "%d \"%s\"\n", i, catalog);
+ }
+
+ fprintf (f, "END\n");
+
+#endif // _WIN32
+
+ fclose (f);
+
+ char *cat_name = new char [strlen (catname) + 1];
+ strcpy (cat_name, catname);
+ if (char *dot = strrchr (cat_name, '.'))
+ *dot = '\0';
+
+ const int ret = rw_system ("gencat %s" RW_CAT_EXT " %s",
+ cat_name, catname);
+
+ delete[] cat_name;
+
+ remove (catname);
+
+ return ret;
}