Skip to content

Commit

Permalink
move setlocale from mlt_factory_init to melt option
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Feb 18, 2022
1 parent 9b6cd25 commit bc532ca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
3 changes: 3 additions & 0 deletions docs/melt.1
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ Set the directory of MLT modules
\fB\-serialise\fR [filename]
Write the commands to a text file
.TP
\fB\-setlocale\fR
Make numeric strings locale-sensitive (legacy support)
.TP
\fB\-silent\fR
Do not display position/transport
.TP
Expand Down
11 changes: 1 addition & 10 deletions src/framework/mlt_factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \file mlt_factory.c
* \brief the factory method interfaces
*
* Copyright (C) 2003-2021 Meltytech, LLC
* Copyright (C) 2003-2022 Meltytech, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <libgen.h>

/** the default subdirectory of the datadir for holding presets */
Expand Down Expand Up @@ -112,14 +111,6 @@ static char* mlt_dirname( char *path )

mlt_repository mlt_factory_init( const char *directory )
{
// Load the system locales
const char* locale = "";
#if defined(_WIN32)
if (getenv("LC_ALL"))
locale = getenv("LC_ALL");
#endif
setlocale( LC_ALL, locale );

if ( ! global_properties )
global_properties = mlt_properties_new( );

Expand Down
35 changes: 30 additions & 5 deletions src/melt/melt.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* melt.c -- MLT command line utility
* Copyright (C) 2002-2021 Meltytech, LLC
* Copyright (C) 2002-2022 Meltytech, LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -28,6 +28,7 @@
#include <limits.h>
#include <unistd.h>
#include <signal.h>
#include <locale.h>

#include <framework/mlt.h>

Expand Down Expand Up @@ -532,6 +533,7 @@ static void show_usage( char *program_name )
" -repeat times Repeat the last cut\n"
" -repository path Set the directory of MLT modules\n"
" -serialise [filename] Write the commands to a text file\n"
" -setlocale Make numeric strings locale-sensitive\n"
" -silent Do not display position/transport\n"
" -split relative-frame Split the last cut into two cuts\n"
" -swap Rearrange the last two cuts\n"
Expand Down Expand Up @@ -751,6 +753,21 @@ static void set_preview_scale(mlt_profile *profile, mlt_profile *backup_profile,
}
}

static mlt_repository setup_factory(const char* repo_path, int set_locale)
{
mlt_repository repo = mlt_factory_init(repo_path);
if (repo && set_locale) {
// Load the system locales
const char* locale = "";
#if defined(_WIN32)
if (getenv("LC_ALL"))
locale = getenv("LC_ALL");
#endif
setlocale( LC_ALL, locale );
}
return repo;
}

int main( int argc, char **argv )
{
int i;
Expand All @@ -767,12 +784,20 @@ int main( int argc, char **argv )
mlt_repository repo = NULL;
const char* repo_path = NULL;
int is_consumer_explicit = 0;
int is_setlocale = 0;

// Handle abnormal exit situations.
signal( SIGSEGV, abnormal_exit_handler );
signal( SIGILL, abnormal_exit_handler );
signal( SIGABRT, abnormal_exit_handler );

for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-setlocale")) {
is_setlocale = 1;
break;
}
}

for ( i = 1; i < argc; i ++ )
{
// Check for serialisation switch
Expand All @@ -793,7 +818,7 @@ int main( int argc, char **argv )
{
// Construct the factory
if ( !repo )
repo = mlt_factory_init( repo_path );
repo = setup_factory(repo_path, is_setlocale);

const char *pname = argv[ ++ i ];
if ( pname && pname[0] != '-' )
Expand All @@ -812,8 +837,8 @@ int main( int argc, char **argv )
{
// Construct the factory
if ( !repo )
repo = mlt_factory_init( repo_path );
repo = setup_factory(repo_path, is_setlocale);

const char *pname = argv[ ++ i ];
if ( pname && pname[0] != '-' )
{
Expand Down Expand Up @@ -918,7 +943,7 @@ int main( int argc, char **argv )

// Construct the factory
if ( !repo )
repo = mlt_factory_init( repo_path );
repo = setup_factory(repo_path, is_setlocale);

// Create profile if not set explicitly
if ( getenv( "MLT_PROFILE" ) )
Expand Down

0 comments on commit bc532ca

Please sign in to comment.