void-packages/srcpkgs/mlt/patches/musl-locale.patch

235 lines
5.6 KiB
Diff

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 2017-01-20 21:18:26.246774282 +0100
+++ src/framework/mlt_property.c 2017-01-20 21:38:19.680752910 +0100
@@ -278,27 +278,10 @@
s = copy;
pos = strrchr( s, ':' );
-#if !defined(__GLIBC__) && !defined(__APPLE__)
- 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(__APPLE__)
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(__APPLE__)
if ( locale )
seconds = strtod_l( s, NULL, locale );
else
-#endif
seconds = strtod( s, NULL );
}
-#if !defined(__GLIBC__) && !defined(__APPLE__)
- 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(__APPLE__)
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(__APPLE__)
- if ( locale ) {
- // Restore the current locale
- setlocale( LC_NUMERIC, orig_localename );
- free( orig_localename );
- pthread_mutex_unlock( &self->mutex );
- }
-#endif
-
return result;
}
}
@@ -1027,35 +975,10 @@
double temp;
char *p = NULL;
-#if defined(__GLIBC__) || defined(__APPLE__)
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(__APPLE__)
- 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 );
}
return result;
@@ -1531,28 +1454,12 @@
char *p = NULL;
int count = 0;
-#if !defined(__GLIBC__) && !defined(__APPLE__)
- 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(__APPLE__)
if ( locale )
temp = strtod_l( value, &p, locale );
else
-#endif
temp = strtod( value, &p );
if ( p != value )
{
@@ -1582,15 +1489,6 @@
value = p;
count ++;
}
-
-#if !defined(__GLIBC__) && !defined(__APPLE__)
- 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_properties.c 2017-01-20 21:18:26.246774282 +0100
+++ src/framework/mlt_properties.c 2017-01-20 21:38:19.679752910 +0100
@@ -140,15 +140,9 @@
{
property_list *list = self->local;
-#if defined(__GLIBC__) || defined(__APPLE__)
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;
@@ -178,7 +172,7 @@
#elif defined(__GLIBC__)
result = list->locale->__names[ LC_NUMERIC ];
#else
- result = list->locale;
+ result = "C";
#endif
#if defined(_WIN32)
if ( result )
@@ -714,12 +708,10 @@
// Determine the value
if ( isdigit( id[ 0 ] ) )
{
-#if defined(__GLIBC__) || defined(__APPLE__)
property_list *list = self->local;
if ( list->locale )
current = strtod_l( id, NULL, list->locale );
else
-#endif
current = strtod( id, NULL );
}
else
@@ -1410,14 +1402,9 @@
free( list->name[ index ] );
}
-#if defined(__GLIBC__) || defined(__APPLE__)
// Cleanup locale
if ( list->locale )
freelocale( list->locale );
-#else
-
- free( list->locale );
-#endif
// Clear up the list
pthread_mutex_destroy( &list->mutex );