]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_properties.c
Implement LC_NUMERIC handling for non-glibc and non-Darwin OS.
[mlt] / src / framework / mlt_properties.c
index c28af8fc514c2043f574b993b9945683cee39b84..887562c3467fee9dff0de058e5e04d885497f054 100644 (file)
@@ -144,12 +144,15 @@ int mlt_properties_set_lcnumeric( mlt_properties self, const char *locale )
        {
                property_list *list = self->local;
 
-#if defined(__linux__) || defined(__DARWIN__)
+#if defined(__GLIBC__) || defined(__DARWIN__)
                if ( list->locale )
                        freelocale( list->locale );
                list->locale = newlocale( LC_NUMERIC_MASK, locale, NULL );
+#else
+               if ( list->locale )
+                       free( list->locale );
+               list->locale = strdup( locale );
 #endif
-               error = list->locale == NULL;
        }
        else
                error = 1;
@@ -173,13 +176,13 @@ const char* mlt_properties_get_lcnumeric( mlt_properties self )
        if ( list->locale )
        {
 #if defined(__DARWIN__)
-               result = querylocale( LC_NUMERIC, list->locale );
-#elif defined(__linux__)
-               result = list->locale->__names[ LC_NUMERIC ];
+        result = querylocale( LC_NUMERIC, list->locale );
+#elif defined(__GLIBC__)
+        result = list->locale->__names[ LC_NUMERIC ];
 #else
-               // TODO: not yet sure what to do on other platforms
+               result = list->locale;
 #endif
-       }
+    }
        return result;
 }
 
@@ -328,11 +331,10 @@ int mlt_properties_preset( mlt_properties self, const char *name )
 
 static inline int generate_hash( const char *name )
 {
-       int hash = 0;
-       int i = 1;
+       unsigned int hash = 5381;
        while ( *name )
-               hash = ( hash + ( i ++ * ( *name ++ & 31 ) ) ) % 199;
-       return hash;
+               hash = hash * 33 + (unsigned int) ( *name ++ );
+       return hash % 199;
 }
 
 /** Copy a serializable property to a properties list that is mirroring this one.
@@ -508,13 +510,12 @@ static inline mlt_property mlt_properties_find( mlt_properties self, const char
        {
                // Check if we're hashed
                if ( list->count > 0 &&
-                       name[ 0 ] == list->name[ i ][ 0 ] &&
                        !strcmp( list->name[ i ], name ) )
                        value = list->value[ i ];
 
                // Locate the item
                for ( i = list->count - 1; value == NULL && i >= 0; i -- )
-                       if ( name[ 0 ] == list->name[ i ][ 0 ] && !strcmp( list->name[ i ], name ) )
+                       if ( !strcmp( list->name[ i ], name ) )
                                value = list->value[ i ];
        }
        mlt_properties_unlock( self );
@@ -1396,10 +1397,13 @@ void mlt_properties_close( mlt_properties self )
                                free( list->name[ index ] );
                        }
 
-#if defined(__linux__) || defined(__DARWIN__)
+#if defined(__GLIBC__) || defined(__DARWIN__)
                        // Cleanup locale
                        if ( list->locale )
                                freelocale( list->locale );
+#else
+                       if ( list->locale )
+                               free( list->locale );
 #endif
 
                        // Clear up the list