[vlc-commits] Remove --disable-non-utf8

Rémi Denis-Courmont git at videolan.org
Mon Mar 19 21:24:18 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 19 22:11:36 2012 +0200| [2abddadedd89111d1d9c0f3ccad172fd9ec519a3] | committer: Rémi Denis-Courmont

Remove --disable-non-utf8

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2abddadedd89111d1d9c0f3ccad172fd9ec519a3
---

 configure.ac          |   14 -------
 include/vlc_charset.h |   31 ++++++++++++++--
 src/libvlccore.sym    |    5 ---
 src/text/unicode.c    |   94 +-----------------------------------------------
 4 files changed, 29 insertions(+), 115 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3cb2574..4c16c28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -763,20 +763,6 @@ fi
 AM_CONDITIONAL(HAVE_MINIZIP, [ test "${have_minizip}" = "yes" ])
 
 
-dnl Manual switch for UTF-8
-AC_ARG_ENABLE(non-utf8,
-  [AS_HELP_STRING([--enable-non-utf8],
-    [support legacy non-UTF-8 systems (default disabled)])],, [
-  AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce" -o "${SYS}" = "os2"], [
-    enable_non_utf8="no"
-  ])
-])
-AS_IF([test "${enable_non_utf8}" != "no"], [
-  AC_DEFINE([ASSUME_UTF8], [1],
-            [Define to 1 if the operating system uses UTF-8 internally])
-])
-
-
 dnl Check for dbus
 AC_ARG_ENABLE(dbus,
   [AS_HELP_STRING([--enable-dbus],
diff --git a/include/vlc_charset.h b/include/vlc_charset.h
index 13583d6..e27af0a 100644
--- a/include/vlc_charset.h
+++ b/include/vlc_charset.h
@@ -51,7 +51,33 @@ VLC_API char * vlc_strcasestr(const char *, const char *) VLC_USED;
 VLC_API char * EnsureUTF8( char * );
 VLC_API const char * IsUTF8( const char * ) VLC_USED;
 
-#ifdef WIN32
+VLC_API char * FromCharset( const char *charset, const void *data, size_t data_size ) VLC_USED;
+VLC_API void * ToCharset( const char *charset, const char *in, size_t *outsize ) VLC_USED;
+
+#ifndef WIN32
+# define FromLocale(l) (l)
+# define ToLocale(u)   (u)
+# define LocaleFree(s) ((void)(s))
+# define FromLocaleDup strdup
+# define ToLocaleDup   strdup
+
+#else
+VLC_USED
+static inline const char *FromLocale (const char *locale)
+{
+    return locale ? FromCharset ("", locale, strlen (locale)) : NULL;
+}
+
+VLC_USED
+static inline const char *ToLocale (const char *utf8)
+{
+    size_t outsize;
+    return utf8 ? ToCharset ("", utf8, &outsize) : NULL;
+}
+# define LocaleFree(s) free((char *)(s))
+# define FromLocaleDup FromLocale
+# define ToLocaleDup   ToLocale
+
 VLC_USED
 static inline char *FromWide (const wchar_t *wide)
 {
@@ -116,9 +142,6 @@ static inline char *FromLatin1 (const char *latin)
     return utf8 ? utf8 : str;
 }
 
-VLC_API char * FromCharset( const char *charset, const void *data, size_t data_size ) VLC_USED;
-VLC_API void * ToCharset( const char *charset, const char *in, size_t *outsize ) VLC_USED;
-
 VLC_API double us_strtod( const char *, char ** ) VLC_USED;
 VLC_API float us_strtof( const char *, char ** ) VLC_USED;
 VLC_API double us_atof( const char * ) VLC_USED;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7dfbbcd..9dcf07f 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -144,8 +144,6 @@ filter_chain_VideoFlush
 filter_ConfigureBlend
 filter_DeleteBlend
 filter_NewBlend
-FromLocale
-FromLocaleDup
 FromCharset
 GetLang_1
 GetLang_2B
@@ -240,7 +238,6 @@ libvlc_InternalInit
 libvlc_InternalWait
 libvlc_Quit
 libvlc_SetExitHandler
-LocaleFree
 make_URI
 make_path
 mdate
@@ -437,8 +434,6 @@ subpicture_region_New
 vlc_tls_ClientCreate
 vlc_tls_ClientDelete
 ToCharset
-ToLocale
-ToLocaleDup
 update_Check
 update_Delete
 update_Download
diff --git a/src/text/unicode.c b/src/text/unicode.c
index 4dd95b3..cfcf55c 100644
--- a/src/text/unicode.c
+++ b/src/text/unicode.c
@@ -48,108 +48,18 @@
 #include <wctype.h>
 
 /**
- * Releases (if needed) a localized or uniformized string.
- * @param str non-NULL return value from FromLocale() or ToLocale().
- */
-void LocaleFree (const char *str)
-{
-#ifdef ASSUME_UTF8
-    (void) str;
-#else
-    free ((char *)str);
-#endif
-}
-
-
-/**
- * Converts a string from the system locale character encoding to UTF-8.
- *
- * @param locale nul-terminated string to convert
- *
- * @return a nul-terminated UTF-8 string, or NULL in case of error.
- * To avoid memory leak, you have to pass the result to LocaleFree()
- * when it is no longer needed.
- */
-char *FromLocale (const char *locale)
-{
-#ifdef ASSUME_UTF8
-    return (char *)locale;
-#else
-    return locale ? FromCharset ("", locale, strlen(locale)) : NULL;
-#endif
-}
-
-/**
- * converts a string from the system locale character encoding to utf-8,
- * the result is always allocated on the heap.
- *
- * @param locale nul-terminated string to convert
- *
- * @return a nul-terminated utf-8 string, or null in case of error.
- * The result must be freed using free() - as with the strdup() function.
- */
-char *FromLocaleDup (const char *locale)
-{
-#ifdef ASSUME_UTF8
-    return strdup (locale);
-#else
-    return FromCharset ("", locale, strlen(locale));
-#endif
-}
-
-
-/**
- * ToLocale: converts an UTF-8 string to local system encoding.
- *
- * @param utf8 nul-terminated string to be converted
- *
- * @return a nul-terminated string, or NULL in case of error.
- * To avoid memory leak, you have to pass the result to LocaleFree()
- * when it is no longer needed.
- */
-char *ToLocale (const char *utf8)
-{
-#ifdef ASSUME_UTF8
-    return (char *)utf8;
-#else
-    size_t outsize;
-    return utf8 ? ToCharset ("", utf8, &outsize) : NULL;
-#endif
-}
-
-
-/**
- * converts a string from UTF-8 to the system locale character encoding,
- * the result is always allocated on the heap.
- *
- * @param utf8 nul-terminated string to convert
- *
- * @return a nul-terminated string, or null in case of error.
- * The result must be freed using free() - as with the strdup() function.
- */
-char *ToLocaleDup (const char *utf8)
-{
-#ifdef ASSUME_UTF8
-    return strdup (utf8);
-#else
-    size_t outsize;
-    return ToCharset ("", utf8, &outsize);
-#endif
-}
-
-/**
  * Formats an UTF-8 string as vfprintf(), then print it, with
  * appropriate conversion to local encoding.
  */
 int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap )
 {
-#ifdef ASSUME_UTF8
+#ifndef WIN32
     return vfprintf (stream, fmt, ap);
 #else
     char *str;
     int res;
 
-# if defined( WIN32 ) && !defined( UNDER_CE )
+# ifndef UNDER_CE
     /* Writing to the console is a lot of fun on Microsoft Windows.
      * If you use the standard I/O functions, you must use the OEM code page,
      * which is different from the usual ANSI code page. Or maybe not, if the



More information about the vlc-commits mailing list