Fix accidental switch/teleporter behavior changes
[neverball] / share / text.c
index 92a6eea..4fcfdb1 100644 (file)
  * General Public License for more details.
  */
 
-#include <stdio.h>
 #include <string.h>
-#include <errno.h>
-
-#if ENABLE_NLS
-#include <iconv.h>
-#endif
-
 #include "text.h"
 
 /*---------------------------------------------------------------------------*/
 
-#define MAXSTR 256
-
-/*---------------------------------------------------------------------------*/
-
-#if ENABLE_NLS
-static iconv_t conv_from_locale = 0;
-static iconv_t conv_to_locale = 0;
-#endif
-
-void text_init(void)
-{
-#if ENABLE_NLS
-    if ((conv_from_locale = iconv_open("UTF-8", "")) == (iconv_t) -1)
-        fprintf(stderr, "Error: %s\n", strerror(errno));
-
-    if ((conv_to_locale = iconv_open("", "UTF-8")) == (iconv_t) -1)
-        fprintf(stderr, "Error: %s\n", strerror(errno));
-#else
-    return;
-#endif
-}
-
-void text_quit(void)
-{
-#if ENABLE_NLS
-    if (conv_from_locale != (iconv_t) -1)
-        iconv_close(conv_from_locale);
-
-    if (conv_to_locale != (iconv_t) -1)
-        iconv_close(conv_to_locale);
-#else
-    return;
-#endif
-}
-
-/*---------------------------------------------------------------------------*/
-
-char *text_from_locale(char *str0)
-{
-#if ENABLE_NLS
-    static char buffer[MAXSTR * 2];
-
-    char *str0p = str0;
-    char *str1p = buffer;
-
-    size_t l0 = strlen(str0);
-    size_t l1 = sizeof (buffer);
-
-    if (conv_from_locale == (iconv_t) -1)
-        return str0;
-
-    if (iconv(conv_from_locale, &str0p, &l0, &str1p, &l1) == (size_t) -1)
-        fprintf(stderr, "Error while converting to UTF-8: %s\n",
-                strerror(errno));
-
-    *str1p = '\0';
-
-    return buffer;
-#else
-    return str0;
-#endif
-}
-
-char *text_to_locale(char *str0)
-{
-#if ENABLE_NLS
-    static char buffer[MAXSTR * 2];
-
-    char *str0p = str0;
-    char *str1p = buffer;
-
-    size_t l0 = strlen(str0);
-    size_t l1 = sizeof (buffer);
-
-    if (conv_to_locale == (iconv_t) -1)
-        return str0;
-
-    if (iconv(conv_to_locale, &str0p, &l0, &str1p, &l1) == (size_t) -1)
-        fprintf(stderr, "Error while converting from UTF-8: %s\n",
-                strerror(errno));
-
-    *str1p = '\0';
-
-    return buffer;
-#else
-    return str0;
-#endif
-}
-
-/*---------------------------------------------------------------------------*/
-
-int text_add_char(Uint32 unicode, char *string, int maxbytes, int maxchars)
+int text_add_char(Uint32 unicode, char *string, int maxbytes)
 {
     size_t pos = strlen(string);
     int l;
@@ -125,7 +27,7 @@ int text_add_char(Uint32 unicode, char *string, int maxbytes, int maxchars)
     else if (unicode < 0x10000) l = 3;
     else                        l = 4;
 
-    if ((pos + l >= maxbytes) || (text_length(string) + 1 >= maxchars))
+    if (pos + l >= maxbytes)
         return 0;
 
     if (unicode < 0x80)