Skip to content

Commit 366c953

Browse files
committed
fix with no arguments
1 parent 8a57957 commit 366c953

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

src/faust_tilde_options.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,47 +79,50 @@ char faust_opt_manager_parse_compile_options(t_faust_opt_manager *x, size_t cons
7979
{
8080
char has_include = 0;
8181
faust_opt_manager_free_compile_options(x);
82-
x->f_options = getbytes(argc * sizeof(char *));
83-
if(x->f_options)
82+
if(argc && argv)
8483
{
85-
size_t i;
86-
for(i = 0; i < argc; ++i)
84+
x->f_options = getbytes(argc * sizeof(char *));
85+
if(x->f_options)
8786
{
88-
x->f_options[i] = (char *)getbytes(MAXFAUSTSTRING * sizeof(char));
89-
if(x->f_options[i])
87+
size_t i;
88+
for(i = 0; i < argc; ++i)
9089
{
91-
if(argv[i].a_type == A_FLOAT)
90+
x->f_options[i] = (char *)getbytes(MAXFAUSTSTRING * sizeof(char));
91+
if(x->f_options[i])
9292
{
93-
sprintf(x->f_options[i], "%i", (int)argv[i].a_w.w_float);
94-
}
95-
else if(argv[i].a_type == A_SYMBOL && argv[i].a_w.w_symbol)
96-
{
97-
sprintf(x->f_options[i], "%s", argv[i].a_w.w_symbol->s_name);
98-
if(!strncmp(x->f_options[i], "-I", 2))
93+
if(argv[i].a_type == A_FLOAT)
9994
{
100-
has_include = 1;
95+
sprintf(x->f_options[i], "%i", (int)argv[i].a_w.w_float);
10196
}
97+
else if(argv[i].a_type == A_SYMBOL && argv[i].a_w.w_symbol)
98+
{
99+
sprintf(x->f_options[i], "%s", argv[i].a_w.w_symbol->s_name);
100+
if(!strncmp(x->f_options[i], "-I", 2))
101+
{
102+
has_include = 1;
103+
}
104+
}
105+
else
106+
{
107+
pd_error(x->f_owner, "faustgen~: option type invalid");
108+
memset(x->f_options[i], 0, MAXFAUSTSTRING);
109+
}
110+
x->f_noptions = i+1;
102111
}
103112
else
104113
{
105-
pd_error(x->f_owner, "faustgen~: option type invalid");
106-
memset(x->f_options[i], 0, MAXFAUSTSTRING);
114+
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile option %i", (int)i);
115+
x->f_noptions = i;
116+
return -1;
107117
}
108-
x->f_noptions = i+1;
109-
}
110-
else
111-
{
112-
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile option %i", (int)i);
113-
x->f_noptions = i;
114-
return -1;
115118
}
116119
}
117-
}
118-
else
119-
{
120-
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile options");
121-
x->f_noptions = 0;
122-
return -1;
120+
else
121+
{
122+
pd_error(x->f_owner, "faustgen~: memory allocation failed - compile options vector");
123+
x->f_noptions = 0;
124+
return -1;
125+
}
123126
}
124127
if(!has_include)
125128
{

src/faustgen_tilde.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ static void faustgen_tilde_compile_options(t_faustgen_tilde *x, t_symbol* s, int
123123
faustgen_tilde_compile(x);
124124
}
125125

126+
/*
126127
static void faustgen_tilde_read(t_faustgen_tilde *x, t_symbol* s)
127128
{
128129
x->f_dsp_name = s;
129130
faustgen_tilde_compile(x);
130131
}
132+
*/
131133

132134
static long faustgen_tilde_get_time(t_faustgen_tilde *x)
133135
{
@@ -361,7 +363,7 @@ static void *faustgen_tilde_new(t_symbol* s, int argc, t_atom* argv)
361363
x->f_opt_manager = faust_opt_manager_new((t_object *)x, canvas_getcurrent());
362364
x->f_dsp_name = atom_getsymbolarg(0, argc, argv);
363365
x->f_clock = clock_new(x, (t_method)faustgen_tilde_autocompile_tick);
364-
faust_opt_manager_parse_compile_options(x->f_opt_manager, argc-1, argv+1);
366+
faust_opt_manager_parse_compile_options(x->f_opt_manager, argc ? argc-1 : 0, argv ? argv+1 : NULL);
365367
if(!argc)
366368
{
367369
return x;

0 commit comments

Comments
 (0)