Use real i18n code on NetBSD/current with per-function locale overrides

as necessary. Bump revision.
This commit is contained in:
joerg 2013-09-08 16:28:27 +00:00
parent 01bd63e51a
commit 5bd7cc3a0c
9 changed files with 310 additions and 7 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.160 2013/09/02 19:51:19 adam Exp $
# $NetBSD: Makefile,v 1.161 2013/09/08 16:28:27 joerg Exp $
#
DISTNAME= vlc-${VLC_VERSION}
PKGREVISION= 32
PKGREVISION= 33
CATEGORIES= multimedia
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=vlc/} \
http://download.videolan.org/pub/videolan/vlc/${VLC_VERSION}/

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.61 2013/06/15 22:57:58 wiz Exp $
$NetBSD: distinfo,v 1.62 2013/09/08 16:28:27 joerg Exp $
SHA1 (vlc-1.1.13.tar.bz2) = 05bbc7ff427f3b919b29a45ce014caff9ba92648
RMD160 (vlc-1.1.13.tar.bz2) = c5aa438a9085ddbf28e849df442b75475693290d
@ -15,9 +15,14 @@ SHA1 (patch-ah) = 6d5d5c0e17bd845fad757e75a9e68db698510374
SHA1 (patch-ai) = 328bd66ef6c11275894c74012e7d6fec8fcbd5d3
SHA1 (patch-ar) = 153164870e9dc50ad32106d9f8ebd25b35ed3dd3
SHA1 (patch-as) = b53b074b2791d7bf69d5f09c7c32d873608f3086
SHA1 (patch-at) = c87d63d438296653bc1bf234452fb48dbb0547e5
SHA1 (patch-at) = d4fe7ba15a64c28f97a2800fe0bcae304ce0fa2d
SHA1 (patch-au) = 7e1d1e7f2734051fffb988cc4ea01a1a7b264b78
SHA1 (patch-configure.ac) = db79a1e99bf2859eeb2615359db9a30a3eadfb2d
SHA1 (patch-include_vlc_fixups.h) = 0e17c6749665b4f95bc13a0aff0bc8af9e942c9d
SHA1 (patch-include_vlc__fixups.h) = b6001b92238e365ccd8e5daf3683f919e472b61d
SHA1 (patch-modules_audio__output_pulse.c) = 994389b214f3e2b7b8b7ccaf3bb535a94523f81b
SHA1 (patch-modules_codec_flac.c) = 962783164f505a8b9e5c1be18e162dfdc7917cb3
SHA1 (patch-modules_misc_rtsp.c) = 586e0228cf21ca2f976451e61e4390278afb6fee
SHA1 (patch-modules_visualization_projectm.cpp) = 8e3c6ec0d9588f432c5baa75e36c1c2248780b6b
SHA1 (patch-src_config_file.c) = f6938d98f0f9b14cd13f8020807aac3c818c58d1
SHA1 (patch-src_misc_messages.c) = 855e82349ec80f7d68404da6b40f367776a74327
SHA1 (patch-src_text_charset.c) = b8dfc376f23655565f671849971293d8527f5e3e

View file

@ -1,6 +1,6 @@
$NetBSD: patch-at,v 1.2 2013/06/15 22:57:58 wiz Exp $
$NetBSD: patch-at,v 1.3 2013/09/08 16:28:27 joerg Exp $
--- bin/override.c.orig 2013-06-15 22:57:03.000000000 +0000
--- bin/override.c.orig 2013-05-15 20:23:06.000000000 +0000
+++ bin/override.c
@@ -27,7 +27,7 @@
@ -20,3 +20,19 @@ $NetBSD: patch-at,v 1.2 2013/06/15 22:57:58 wiz Exp $
{
if (override)
{
@@ -245,6 +245,7 @@ error:
*/
#include <locale.h>
+#if 0
char *setlocale (int cat, const char *locale)
{
if (override && locale != NULL)
@@ -254,6 +255,7 @@ char *setlocale (int cat, const char *lo
}
return CALL(setlocale, cat, locale);
}
+#endif
/*** Xlib ****/

View file

@ -0,0 +1,31 @@
$NetBSD: patch-include_vlc__fixups.h,v 1.1 2013/09/08 16:28:27 joerg Exp $
--- include/vlc_fixups.h.orig 2013-05-15 20:39:43.000000000 +0000
+++ include/vlc_fixups.h
@@ -177,25 +177,7 @@ static inline char *getenv (const char *
# define ATTR_ALIGN(align)
#endif
-#ifndef HAVE_USELOCALE
-#define LC_NUMERIC_MASK 0
-#define LC_MESSAGES_MASK 0
-typedef void *locale_t;
-static inline locale_t uselocale(locale_t loc)
-{
- (void)loc;
- return NULL;
-}
-static inline void freelocale(locale_t loc)
-{
- (void)loc;
-}
-static inline locale_t newlocale(int mask, const char * locale, locale_t base)
-{
- (void)mask; (void)locale; (void)base;
- return NULL;
-}
-#endif
+#include <locale.h>
#ifdef WIN32
# include <dirent.h>

View file

@ -0,0 +1,33 @@
$NetBSD: patch-modules_misc_rtsp.c,v 1.1 2013/09/08 16:28:27 joerg Exp $
--- modules/misc/rtsp.c.orig 2013-05-15 20:28:04.000000000 +0000
+++ modules/misc/rtsp.c
@@ -952,22 +952,26 @@ static void RtspClientDel( vod_media_t *
static float ParseNPT (const char *str)
{
+#ifndef LC_C_LOCALE
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t oldloc = uselocale (loc);
+#endif
unsigned hour, min;
float sec;
- if (sscanf (str, "%u:%u:%f", &hour, &min, &sec) == 3)
+ if (sscanf_l (str, LC_C_LOCALE, "%u:%u:%f", &hour, &min, &sec) == 3)
sec += ((hour * 60) + min) * 60;
else
- if (sscanf (str, "%f", &sec) != 1)
+ if (sscanf_l (str, LC_C_LOCALE, "%f", &sec) != 1)
sec = 0.;
+#ifndef LC_C_LOCALE
if (loc != (locale_t)0)
{
uselocale (oldloc);
freelocale (loc);
}
+#endif
return sec;
}

View file

@ -0,0 +1,29 @@
$NetBSD: patch-modules_visualization_projectm.cpp,v 1.1 2013/09/08 16:28:27 joerg Exp $
--- modules/visualization/projectm.cpp.orig 2013-05-15 20:28:01.000000000 +0000
+++ modules/visualization/projectm.cpp
@@ -344,8 +344,10 @@ static void *Thread( void *p_data )
goto error;
}
+#ifndef LC_C_LOCALE
loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
oldloc = uselocale (loc);
+#endif
/* Create the projectM object */
#ifndef HAVE_PROJECTM2
psz_config = var_InheritString( p_filter, "projectm-config" );
@@ -428,11 +430,13 @@ static void *Thread( void *p_data )
delete p_projectm;
vout_DeleteDisplay( p_sys->p_vd, NULL );
vlc_object_release( p_sys->p_vout );
+#ifndef LC_C_LOCALE
if (loc != (locale_t)0)
{
uselocale (oldloc);
freelocale (loc);
}
+#endif
return NULL;
}
vlc_mutex_unlock( &p_sys->lock );

View file

@ -0,0 +1,63 @@
$NetBSD: patch-src_config_file.c,v 1.1 2013/09/08 16:28:27 joerg Exp $
--- src/config/file.c.orig 2013-05-15 20:27:58.000000000 +0000
+++ src/config/file.c
@@ -187,8 +187,10 @@ int config_LoadConfigFile( vlc_object_t
section[0] = '\0';
/* Ensure consistent number formatting... */
+#ifndef LC_C_LOCALE
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t baseloc = uselocale (loc);
+#endif
vlc_rwlock_wrlock (&config_lock);
while (fgets (line, 1024, file) != NULL)
@@ -282,7 +284,7 @@ int config_LoadConfigFile( vlc_object_t
case CONFIG_ITEM_FLOAT:
if( !*psz_option_value )
break; /* ignore empty option */
- p_item->value.f = (float)atof (psz_option_value);
+ p_item->value.f = strtof_l(psz_option_value, NULL, LC_C_LOCALE);
p_item->saved.f = p_item->value.f;
break;
@@ -315,11 +317,13 @@ int config_LoadConfigFile( vlc_object_t
fclose (file);
module_list_free (list);
+#ifndef LC_C_LOCALE
if (loc != (locale_t)0)
{
uselocale (baseloc);
freelocale (loc);
}
+#endif
return 0;
}
@@ -570,8 +574,10 @@ static int SaveConfigFile( vlc_object_t
"\n" );
/* Ensure consistent number formatting... */
+#ifndef LC_C_LOCALE
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t baseloc = uselocale (loc);
+#endif
/* We would take the config lock here. But this would cause a lock
* inversion with the serializer above and config_AutoSaveConfigFile().
@@ -683,11 +689,13 @@ static int SaveConfigFile( vlc_object_t
vlc_rwlock_unlock (&config_lock);
module_list_free (list);
+#ifndef LC_C_LOCALE
if (loc != (locale_t)0)
{
uselocale (baseloc);
freelocale (loc);
}
+#endif
/*
* Restore old settings from the config in file

View file

@ -0,0 +1,65 @@
$NetBSD: patch-src_misc_messages.c,v 1.1 2013/09/08 16:28:27 joerg Exp $
--- src/misc/messages.c.orig 2010-08-08 17:32:50.000000000 +0000
+++ src/misc/messages.c
@@ -301,7 +301,9 @@ void msg_GenericVa (vlc_object_t *p_this
return;
msg_bank_t *bank = libvlc_bank (p_this->p_libvlc);
+#ifndef LC_C_LOCALE
locale_t locale = uselocale (bank->locale);
+#endif
#ifndef __GLIBC__
/* Expand %m to strerror(errno) - only once */
@@ -321,7 +323,9 @@ void msg_GenericVa (vlc_object_t *p_this
char errbuf[2001];
size_t errlen;
-#ifndef WIN32
+#ifdef LC_C_LOCALE
+ strncpy(errbuf, strerror_l( errno, bank->locale), 1001);
+#elif !defined(WIN32)
strerror_r( errno, errbuf, 1001 );
#else
int sockerr = WSAGetLastError( );
@@ -361,7 +365,7 @@ void msg_GenericVa (vlc_object_t *p_this
/* Convert message to string */
vlc_va_copy( args, _args );
- if( vasprintf( &psz_str, psz_format, args ) == -1 )
+ if( vasprintf_l( &psz_str, bank->locale, psz_format, args ) == -1 )
psz_str = NULL;
va_end( args );
@@ -372,7 +376,9 @@ void msg_GenericVa (vlc_object_t *p_this
fprintf( stderr, "main warning: can't store message (%m): " );
#else
char psz_err[1001];
-#ifndef WIN32
+#ifdef LC_C_LOCALE
+ strncpy(psz_err, strerror_l( errno, bank->locale), 1001 );
+#elif !defined(WIN32)
/* we're not using GLIBC, so we are sure that the error description
* will be stored in the buffer we provide to strerror_r() */
strerror_r( errno, psz_err, 1001 );
@@ -384,14 +390,18 @@ void msg_GenericVa (vlc_object_t *p_this
#endif
vlc_va_copy( args, _args );
/* We should use utf8_vfprintf - but it calls malloc()... */
- vfprintf( stderr, psz_format, args );
+ vfprintf_l( stderr, bank->locale, psz_format, args );
va_end( args );
fputs( "\n", stderr );
vlc_restorecancel (canc);
+#ifndef LC_C_LOCALE
uselocale (locale);
+#endif
return;
}
+#ifndef LC_C_LOCALE
uselocale (locale);
+#endif
msg_item_t * p_item = malloc (sizeof (*p_item));
if (p_item == NULL)

View file

@ -0,0 +1,61 @@
$NetBSD: patch-src_text_charset.c,v 1.1 2013/09/08 16:28:27 joerg Exp $
--- src/text/charset.c.orig 2013-05-15 20:27:52.000000000 +0000
+++ src/text/charset.c
@@ -78,6 +78,9 @@ char *vlc_fix_readdir( const char *psz_s
*/
double us_strtod( const char *str, char **end )
{
+#ifdef LC_C_LOCALE
+ return strtod_l(str, end, LC_C_LOCALE);
+#else
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t oldloc = uselocale (loc);
double res = strtod (str, end);
@@ -88,6 +91,7 @@ double us_strtod( const char *str, char
freelocale (loc);
}
return res;
+#endif
}
@@ -97,6 +101,9 @@ double us_strtod( const char *str, char
*/
float us_strtof( const char *str, char **end )
{
+#ifdef LC_C_LOCALE
+ return strtof_l(str, end, LC_C_LOCALE);
+#else
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t oldloc = uselocale (loc);
float res = strtof (str, end);
@@ -107,6 +114,7 @@ float us_strtof( const char *str, char *
freelocale (loc);
}
return res;
+#endif
}
@@ -126,6 +134,14 @@ double us_atof( const char *str )
*/
int us_asprintf( char **ret, const char *format, ... )
{
+#ifdef LC_C_LOCALE
+ va_list ap;
+ int i_rc;
+ va_start( ap, format );
+ i_rc = vasprintf_l( ret, LC_C_LOCALE, format, ap );
+ va_end( ap );
+ return i_rc;
+#else
va_list ap;
locale_t loc = newlocale( LC_NUMERIC_MASK, "C", NULL );
locale_t oldloc = uselocale( loc );
@@ -142,4 +158,5 @@ int us_asprintf( char **ret, const char
}
return i_rc;
+#endif
}