> -----Original Message----- > From: Martin Sebor [mailto:[EMAIL PROTECTED] > Sent: Friday, July 13, 2007 5:53 PM > To: stdcxx-dev@incubator.apache.org > Subject: Re: svn commit: r555006 - > /incubator/stdcxx/trunk/src/catalog.cpp > > >> If it does, is the bug easily > >> reproducible so we can add a test case for it to the bug tracking > >> database?
The JIRA issue created: http://issues.apache.org/jira/browse/STDCXX-508 > > For the test case the valid catalog should be created > (.dll file on > > windows). > > It's not so easy and platform dependent. Of course we can use > > generate_catalog () function from 22.locale.messages.cpp test. > > That seems like a good approach. We could use it as the first > step toward providing an easier and portable way to build > message catalogs on Windows as well as other platforms. A > portable utility that takes a source file such as > rwstderr.msg or rwstderr.rc as input and produces a catalog > from it suitable for the target platform. Attached is a new utility for generating the message catalogs on Windows. ChangeLog: * gencat.cpp: New utility for generating the message catalogs on Windows. Farid.
/*************************************************************************** * * gencat.cpp - Utility for generating message catalogs on Windows * * $Id: $ * *************************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. * **************************************************************************/ #ifndef _WIN32 #error This utility should be compiled only on Windows #endif #include <cstdlib> // for system(), getenv() #include <cstdio> // for printf() #include <cstring> // for strcmp(), strrchr() #include <cstddef> // for size_t #include <string> static const char usage_text[] = { "Usage: %s OUTPUT-FILE INPUT-FILE\n" "Generate message catalog.\n" "\n" " -?, --help Give this help list\n" }; #ifndef _WIN64 # define PLATFORM "X86" #else // _WIN64 # define PLATFORM "X64" #endif // _WIN64 // replace file extension in str by new extension ext static void change_ext (std::string& str, const char* ext) { const std::string::size_type npos = std::string::npos; std::string::size_type dot_pos = str.find_last_of ('.'); std::string::size_type quote_pos = npos == dot_pos ? str.find_last_of ('\"') : str.find_first_of ('\"', dot_pos); if (npos == quote_pos) quote_pos = str.size (); if (npos == dot_pos) dot_pos = quote_pos; str.replace (dot_pos, quote_pos - dot_pos, ext); } int main (int argc, char *argv[]) { const char* exe_name = std::strrchr (argv [0], '\\'); if (exe_name) ++exe_name; else exe_name = argv [0]; if (1 == argc) { std::printf (usage_text, exe_name); return 0; } --argc; while (0 != *++argv && 0 < argc-- && '-' == **argv) { switch (*++*argv) { case '?': std::printf (usage_text, exe_name); return 0; case '-': if (0 == std::strcmp (*argv, "-help")) { std::printf (usage_text, exe_name); return 0; } // fall through... default: std::printf ("%s: invalid option -%s\n", exe_name, *argv); return 1; } } if (1 > argc) { std::printf ("%s: missing arguments\n Try '%s --help'\n", exe_name, exe_name); return 1; } const char* const env_vars [] = { "VS80COMNTOOLS", "VS71COMNTOOLS", "VSCOMNTOOLS" }; std::string cmd; for (size_t i = 0; i < sizeof (env_vars) / sizeof (*env_vars); ++i) { if (const char* vcvarspath = std::getenv (env_vars [i])) { cmd = vcvarspath; cmd += "vsvars32.bat"; break; } } if (std::string::npos != cmd.find (' ')) { cmd.insert (0, 1, '\"'); cmd.push_back ('\"'); } const char* const dll_name = argv [0]; const char* const rc_name = argv [1]; std::string res_name (rc_name); change_ext (res_name, ".res"); if (!cmd.empty ()) cmd += " && "; cmd += "rc "; cmd += rc_name; cmd += " && link /NOLOGO /DLL /NOENTRY /MACHINE:" PLATFORM " /OUT:"; cmd += dll_name; cmd += ' '; cmd += res_name; const int ret = std::system (cmd.c_str ()); std::remove (res_name.c_str ()); return ret; }