mlt: unbreak musl

This commit is contained in:
Jürgen Buchmüller 2015-08-21 20:12:10 +02:00
parent 9baf36449f
commit b6a1720c8e
2 changed files with 279 additions and 1 deletions

View File

@ -0,0 +1,278 @@
Remove the wrong assumptions that if __GLIBC__ isn't defined,
then strtod_l() would not exist. It exists with musl libc as well.
Also don't assume locale_t == char* if __GLIBC__ isn't defined.
--- src/framework/mlt_property.c 2015-03-02 08:08:46.000000000 +0100
+++ src/framework/mlt_property.c 2015-08-21 19:56:33.439349125 +0200
@@ -278,27 +278,10 @@
s = copy;
pos = strrchr( s, ':' );
-#if !defined(__GLIBC__) && !defined(__DARWIN__)
- char *orig_localename = NULL;
- if ( locale )
- {
- // Protect damaging the global locale from a temporary locale on another thread.
- pthread_mutex_lock( &self->mutex );
-
- // Get the current locale
- orig_localename = strdup( setlocale( LC_NUMERIC, NULL ) );
-
- // Set the new locale
- setlocale( LC_NUMERIC, locale );
- }
-#endif
-
if ( pos ) {
-#if defined(__GLIBC__) || defined(__DARWIN__)
if ( locale )
seconds = strtod_l( pos + 1, NULL, locale );
else
-#endif
seconds = strtod( pos + 1, NULL );
*pos = 0;
pos = strrchr( s, ':' );
@@ -312,23 +295,12 @@
}
}
else {
-#if defined(__GLIBC__) || defined(__DARWIN__)
if ( locale )
seconds = strtod_l( s, NULL, locale );
else
-#endif
seconds = strtod( s, NULL );
}
-#if !defined(__GLIBC__) && !defined(__DARWIN__)
- if ( locale ) {
- // Restore the current locale
- setlocale( LC_NUMERIC, orig_localename );
- free( orig_localename );
- pthread_mutex_unlock( &self->mutex );
- }
-#endif
-
free( copy );
return lrint( fps * ( (hours * 3600) + (minutes * 60) + seconds ) );
@@ -489,37 +461,13 @@
char *end = NULL;
double result;
-#if defined(__GLIBC__) || defined(__DARWIN__)
if ( locale )
result = strtod_l( value, &end, locale );
else
-#else
- char *orig_localename = NULL;
- if ( locale ) {
- // Protect damaging the global locale from a temporary locale on another thread.
- pthread_mutex_lock( &self->mutex );
-
- // Get the current locale
- orig_localename = strdup( setlocale( LC_NUMERIC, NULL ) );
-
- // Set the new locale
- setlocale( LC_NUMERIC, locale );
- }
-#endif
-
result = strtod( value, &end );
if ( end && end[0] == '%' )
result /= 100.0;
-#if !defined(__GLIBC__) && !defined(__DARWIN__)
- if ( locale ) {
- // Restore the current locale
- setlocale( LC_NUMERIC, orig_localename );
- free( orig_localename );
- pthread_mutex_unlock( &self->mutex );
- }
-#endif
-
return result;
}
}
@@ -700,7 +648,9 @@
#elif defined(__GLIBC__)
const char *localename = locale->__names[ LC_NUMERIC ];
#else
- const char *localename = locale;
+ // TODO: not yet sure what to do on other platforms
+ // This is wrong, but we can't get the LC_NUMERIC value from locale
+ const char *localename = "C";
#endif
// Protect damaging the global locale from a temporary locale on another thread.
pthread_mutex_lock( &self->mutex );
@@ -934,7 +884,8 @@
const char *localename = locale->__names[ LC_NUMERIC ];
#else
// TODO: not yet sure what to do on other platforms
- const char *localename = locale;
+ // This is wrong, but we can't get the LC_NUMERIC value from locale
+ const char *localename = "C";
#endif
// Protect damaging the global locale from a temporary locale on another thread.
pthread_mutex_lock( &self->mutex );
@@ -1023,34 +974,10 @@
double temp;
char *p = NULL;
-#if defined(__GLIBC__) || defined(__DARWIN__)
if ( locale )
temp = strtod_l( self->prop_string, &p, locale );
else
-#else
- char *orig_localename = NULL;
- if ( locale ) {
- // Protect damaging the global locale from a temporary locale on another thread.
- pthread_mutex_lock( &self->mutex );
-
- // Get the current locale
- orig_localename = strdup( setlocale( LC_NUMERIC, NULL ) );
-
- // Set the new locale
- setlocale( LC_NUMERIC, locale );
- }
-#endif
-
- temp = strtod( self->prop_string, &p );
-
-#if !defined(__GLIBC__) && !defined(__DARWIN__)
- if ( locale ) {
- // Restore the current locale
- setlocale( LC_NUMERIC, orig_localename );
- free( orig_localename );
- pthread_mutex_unlock( &self->mutex );
- }
-#endif
+ temp = strtod( self->prop_string, &p );
result = ( p != self->prop_string );
}
@@ -1519,28 +1446,12 @@
char *p = NULL;
int count = 0;
-#if !defined(__GLIBC__) && !defined(__DARWIN__)
- char *orig_localename = NULL;
- if ( locale ) {
- // Protect damaging the global locale from a temporary locale on another thread.
- pthread_mutex_lock( &self->mutex );
-
- // Get the current locale
- orig_localename = strdup( setlocale( LC_NUMERIC, NULL ) );
-
- // Set the new locale
- setlocale( LC_NUMERIC, locale );
- }
-#endif
-
while ( *value )
{
double temp;
-#if defined(__GLIBC__) || defined(__DARWIN__)
if ( locale )
temp = strtod_l( value, &p, locale );
- else
-#endif
+ else
temp = strtod( value, &p );
if ( p != value )
{
@@ -1570,16 +1481,7 @@
value = p;
count ++;
}
-
-#if !defined(__GLIBC__) && !defined(__DARWIN__)
- if ( locale ) {
- // Restore the current locale
- setlocale( LC_NUMERIC, orig_localename );
- free( orig_localename );
- pthread_mutex_unlock( &self->mutex );
- }
-#endif
- }
+ }
return rect;
}
--- src/framework/mlt_property.h 2015-03-02 08:08:46.000000000 +0100
+++ src/framework/mlt_property.h 2015-08-21 20:01:15.873374448 +0200
@@ -33,7 +33,7 @@
#if defined(__GLIBC__) || defined(__DARWIN__) || (__FreeBSD_version >= 900506)
#include <xlocale.h>
#else
-typedef char* locale_t;
+#include <locale.h>
#endif
extern mlt_property mlt_property_init( );
--- src/framework/mlt_properties.c 2015-03-02 08:08:46.000000000 +0100
+++ src/framework/mlt_properties.c 2015-08-21 20:08:59.699416035 +0200
@@ -140,15 +140,9 @@
{
property_list *list = self->local;
-#if defined(__GLIBC__) || defined(__DARWIN__)
if ( list->locale )
freelocale( list->locale );
list->locale = newlocale( LC_NUMERIC_MASK, locale, NULL );
-#else
-
- free( list->locale );
- list->locale = strdup( locale );
-#endif
}
else
error = 1;
@@ -174,13 +168,13 @@
if ( list->locale )
{
#if defined(__DARWIN__)
- result = querylocale( LC_NUMERIC, list->locale );
+ result = querylocale( LC_NUMERIC, list->locale );
#elif defined(__GLIBC__)
- result = list->locale->__names[ LC_NUMERIC ];
+ result = list->locale->__names[ LC_NUMERIC ];
#else
- result = list->locale;
+ result = "C";
#endif
- }
+ }
return result;
}
@@ -699,12 +693,10 @@
// Determine the value
if ( isdigit( id[ 0 ] ) )
{
-#if defined(__GLIBC__) || defined(__DARWIN__)
property_list *list = self->local;
if ( list->locale )
current = strtod_l( id, NULL, list->locale );
- else
-#endif
+ else
current = strtod( id, NULL );
}
else
@@ -1395,14 +1387,9 @@
free( list->name[ index ] );
}
-#if defined(__GLIBC__) || defined(__DARWIN__)
// Cleanup locale
if ( list->locale )
freelocale( list->locale );
-#else
-
- free( list->locale );
-#endif
// Clear up the list
pthread_mutex_destroy( &list->mutex );

View File

@ -1,7 +1,7 @@
# Template file for 'mlt'
pkgname=mlt
version=0.9.6
revision=2
revision=3
build_style=gnu-configure
configure_args="--enable-gpl --enable-gpl3"
hostmakedepends="doxygen pkg-config ladspa-sdk"