[Supertux-Commit] [tinygettext commit] r147 - in branches/tinygettext-portable: src test

codesite-noreply at google.com codesite-noreply at google.com
Mon Feb 2 04:15:24 PST 2009


Author: grumbel
Date: Mon Feb  2 03:54:27 2009
New Revision: 147

Modified:
    branches/tinygettext-portable/src/SConscript
    branches/tinygettext-portable/src/iconv.cpp
    branches/tinygettext-portable/src/iconv.hpp
    branches/tinygettext-portable/test/SConscript
    branches/tinygettext-portable/test/tinygettext.cpp

Log:
Added way to use SDL's iconv (little ugly)

Modified: branches/tinygettext-portable/src/SConscript
==============================================================================
--- branches/tinygettext-portable/src/SConscript	(original)
+++ branches/tinygettext-portable/src/SConscript	Mon Feb  2 03:54:27 2009
@@ -1,7 +1,7 @@
  # -*- python -*-

-env =  
Environment(CXXFLAGS=['-g', '-O0', '-ansi', '-pedantic', '-Wall', '-Werror'])
-env.ParseConfig("sdl-config --cflags --libs")
+env =  
Environment(CXXFLAGS=['-g', '-O2', '-ansi', '-pedantic', '-Wall', '-Werror'])
+# env.ParseConfig("sdl-config --cflags --libs")
  env.StaticLibrary('tinygettext',
                    ['tinygettext.cpp',
                     'language.cpp',

Modified: branches/tinygettext-portable/src/iconv.cpp
==============================================================================
--- branches/tinygettext-portable/src/iconv.cpp	(original)
+++ branches/tinygettext-portable/src/iconv.cpp	Mon Feb  2 03:54:27 2009
@@ -47,14 +47,14 @@
  IConv::~IConv()
  {
    if (cd)
-    iconv_close(cd);
+    tinygettext_iconv_close(cd);
  }

  void
  IConv::set_charsets(const std::string& from_charset_, const std::string&  
to_charset_)
  {
    if (cd)
-    iconv_close(cd);
+    tinygettext_iconv_close(cd);

    from_charset = from_charset_;
    to_charset   = to_charset_;
@@ -71,7 +71,7 @@
      }
    else
      {
-      cd = iconv_open(to_charset.c_str(), from_charset.c_str());
+      cd = tinygettext_iconv_open(to_charset.c_str(),  
from_charset.c_str());
        if (cd == (iconv_t)-1)
          {
            if(errno == EINVAL)
@@ -111,12 +111,12 @@
        char* outbuf = &result[0];

        // Try to convert the text.
-      size_t ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+      size_t ret = tinygettext_iconv(cd, &inbuf, &inbytesleft, &outbuf,  
&outbytesleft);
        if (ret == (size_t)-1)
          {
            if (errno == EILSEQ || errno == EINVAL)
              { // invalid multibyte sequence
-              iconv(cd, NULL, NULL, NULL, NULL); // reset state
+              tinygettext_iconv(cd, NULL, NULL, NULL, NULL); // reset state

                // FIXME: Could try to skip the invalid byte and continue
                log_error << "error: tinygettext:iconv: invalid multibyte  
sequence in:  \"" << text << "\"" << std::endl;

Modified: branches/tinygettext-portable/src/iconv.hpp
==============================================================================
--- branches/tinygettext-portable/src/iconv.hpp	(original)
+++ branches/tinygettext-portable/src/iconv.hpp	Mon Feb  2 03:54:27 2009
@@ -20,7 +20,23 @@
  #define HEADER_ICONV_HPP

  #include <string>
-#include <iconv.h>
+
+#ifdef HAVE_SDL
+#  include "SDL.h"
+
+#  define ICONV_CONST const
+#  define tinygettext_iconv_t     SDL_iconv_t
+#  define tinygettext_iconv       SDL_iconv
+#  define tinygettext_iconv_open  SDL_iconv_open
+#  define tinygettext_iconv_close SDL_iconv_close
+#else
+#  include <iconv.h>
+
+#  define tinygettext_iconv_t     iconv_t
+#  define tinygettext_iconv       iconv
+#  define tinygettext_iconv_open  iconv_open
+#  define tinygettext_iconv_close iconv_close
+#endif

  namespace tinygettext {

@@ -29,7 +45,7 @@
  private:
    std::string to_charset;
    std::string from_charset;
-  iconv_t cd;
+  tinygettext_iconv_t cd;

  public:
    IConv();

Modified: branches/tinygettext-portable/test/SConscript
==============================================================================
--- branches/tinygettext-portable/test/SConscript	(original)
+++ branches/tinygettext-portable/test/SConscript	Mon Feb  2 03:54:27 2009
@@ -1,6 +1,7 @@
  # -*- python -*-

-env =  
Environment(CXXFLAGS=['-g', '-O0', '-ansi', '-pedantic', '-Wall', '-Werror'],  
CPPPATH=['../src'])
+env =  
Environment(CXXFLAGS=['-g', '-O2', '-ansi', '-pedantic', '-Wall', '-Werror'],  
CPPPATH=['../src'])
+# env.ParseConfig("sdl-config --cflags --libs")
  env.Program('tinygettext', ['tinygettext.cpp', '../src/libtinygettext.a'])
  env.Program('po_parser_test',  
['po_parser_test.cpp', '../src/libtinygettext.a'])


Modified: branches/tinygettext-portable/test/tinygettext.cpp
==============================================================================
--- branches/tinygettext-portable/test/tinygettext.cpp	(original)
+++ branches/tinygettext-portable/test/tinygettext.cpp	Mon Feb  2 03:54:27  
2009
@@ -56,7 +56,7 @@
      {
        if (argc == 3 && strcmp(argv[1], "language") == 0)
          {
-          Language language = Language::from_env(argv[2]);
+          Language language = Language::from_name(argv[2]);

            if (language)
              std::cout << "Name:      " << language.get_name()      <<  
std::endl


More information about the Supertux-Commit mailing list