Skip to content

Commit

Permalink
fix with no arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Jul 27, 2018
1 parent 8a57957 commit 366c953
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
61 changes: 32 additions & 29 deletions src/faust_tilde_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,47 +79,50 @@ char faust_opt_manager_parse_compile_options(t_faust_opt_manager *x, size_t cons
{
char has_include = 0;
faust_opt_manager_free_compile_options(x);
x->f_options = getbytes(argc * sizeof(char *));
if(x->f_options)
if(argc && argv)
{
size_t i;
for(i = 0; i < argc; ++i)
x->f_options = getbytes(argc * sizeof(char *));
if(x->f_options)
{
x->f_options[i] = (char *)getbytes(MAXFAUSTSTRING * sizeof(char));
if(x->f_options[i])
size_t i;
for(i = 0; i < argc; ++i)
{
if(argv[i].a_type == A_FLOAT)
x->f_options[i] = (char *)getbytes(MAXFAUSTSTRING * sizeof(char));
if(x->f_options[i])
{
sprintf(x->f_options[i], "%i", (int)argv[i].a_w.w_float);
}
else if(argv[i].a_type == A_SYMBOL && argv[i].a_w.w_symbol)
{
sprintf(x->f_options[i], "%s", argv[i].a_w.w_symbol->s_name);
if(!strncmp(x->f_options[i], "-I", 2))
if(argv[i].a_type == A_FLOAT)
{
has_include = 1;
sprintf(x->f_options[i], "%i", (int)argv[i].a_w.w_float);
}
else if(argv[i].a_type == A_SYMBOL && argv[i].a_w.w_symbol)
{
sprintf(x->f_options[i], "%s", argv[i].a_w.w_symbol->s_name);
if(!strncmp(x->f_options[i], "-I", 2))
{
has_include = 1;
}
}
else
{
pd_error(x->f_owner, "faustgen~: option type invalid");
memset(x->f_options[i], 0, MAXFAUSTSTRING);
}
x->f_noptions = i+1;
}
else
{
pd_error(x->f_owner, "faustgen~: option type invalid");
memset(x->f_options[i], 0, MAXFAUSTSTRING);
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile option %i", (int)i);
x->f_noptions = i;
return -1;
}
x->f_noptions = i+1;
}
else
{
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile option %i", (int)i);
x->f_noptions = i;
return -1;
}
}
}
else
{
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile options");
x->f_noptions = 0;
return -1;
else
{
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile options vector");
x->f_noptions = 0;
return -1;
}
}
if(!has_include)
{
Expand Down
4 changes: 3 additions & 1 deletion src/faustgen_tilde.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ static void faustgen_tilde_compile_options(t_faustgen_tilde *x, t_symbol* s, int
faustgen_tilde_compile(x);
}

/*
static void faustgen_tilde_read(t_faustgen_tilde *x, t_symbol* s)
{
x->f_dsp_name = s;
faustgen_tilde_compile(x);
}
*/

static long faustgen_tilde_get_time(t_faustgen_tilde *x)
{
Expand Down Expand Up @@ -361,7 +363,7 @@ static void *faustgen_tilde_new(t_symbol* s, int argc, t_atom* argv)
x->f_opt_manager = faust_opt_manager_new((t_object *)x, canvas_getcurrent());
x->f_dsp_name = atom_getsymbolarg(0, argc, argv);
x->f_clock = clock_new(x, (t_method)faustgen_tilde_autocompile_tick);
faust_opt_manager_parse_compile_options(x->f_opt_manager, argc-1, argv+1);
faust_opt_manager_parse_compile_options(x->f_opt_manager, argc ? argc-1 : 0, argv ? argv+1 : NULL);
if(!argc)
{
return x;
Expand Down

0 comments on commit 366c953

Please sign in to comment.