diff options
Diffstat (limited to 'src/list2lists.c')
-rw-r--r-- | src/list2lists.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/list2lists.c b/src/list2lists.c index 14d553e..8467d57 100644 --- a/src/list2lists.c +++ b/src/list2lists.c @@ -1,4 +1,4 @@ -/* +/* * list2lists: split a list into several sublists given by their lenghts * * (c) 1999-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem) @@ -7,12 +7,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -31,8 +31,7 @@ static t_class *list2lists_class; -typedef struct _list2lists -{ +typedef struct _list2lists { t_object x_obj; t_outlet *x_outlet; @@ -45,7 +44,8 @@ typedef struct _list2lists -static void list2lists_list2(t_list2lists*x,t_symbol*s, int argc, t_atom*argv) +static void list2lists_list2(t_list2lists*x,t_symbol*s, int argc, + t_atom*argv) { if(x->x_length!=0) { freebytes(x->x_length, sizeof(t_atom)*x->x_lcount); @@ -62,8 +62,8 @@ static void list2lists_list2(t_list2lists*x,t_symbol*s, int argc, t_atom*argv) for(i=0; i<argc; i++) { int index=atom_getint(argv+i); if(index<0) { - pd_error(x, "[list2lists]: clamped negative index=%d to 0!", index); - index=0; + pd_error(x, "[list2lists]: clamped negative index=%d to 0!", index); + index=0; } x->x_length[i]=index; } @@ -72,19 +72,21 @@ static void list2lists_list2(t_list2lists*x,t_symbol*s, int argc, t_atom*argv) DEBUGFUN(post("list2: %d %x", x->x_lcount, x->x_length)); } -static void list2lists_output(t_list2lists*x, int argc, t_atom*argv) +static void list2lists_output(t_list2lists*x, int argc, t_atom*argv) { t_outlet*out=x->x_obj.ob_outlet; - if(argc<=0) + if(argc<=0) { outlet_bang(out); - else + } else { outlet_list(out, gensym("list"), argc, argv); + } } -static void list2lists_list(t_list2lists *x, t_symbol *s, int argc, t_atom *argv) +static void list2lists_list(t_list2lists *x, t_symbol *s, int argc, + t_atom *argv) { int i; - + if(x->x_lcount<1) { outlet_anything(x->x_obj.ob_outlet, s, argc, argv); return; @@ -103,7 +105,7 @@ static void list2lists_list(t_list2lists *x, t_symbol *s, int argc, t_atom *argv } static void list2lists_free(t_list2lists *x) -{ +{ if(x->x_length) { freebytes(x->x_length, x->x_lcount*sizeof(int)); x->x_length=0; @@ -118,7 +120,8 @@ static void *list2lists_new(t_symbol* UNUSED(s), int argc, t_atom *argv) t_list2lists *x = (t_list2lists *)pd_new(list2lists_class); outlet_new(&x->x_obj, 0); - x->x_lengin=inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("lst2")); + x->x_lengin=inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), + gensym("lst2")); x->x_lcount=0; x->x_length=0; @@ -136,11 +139,14 @@ static void list2lists_help(t_list2lists*x) void list2lists_setup(void) { - list2lists_class = class_new(gensym("list2lists"), (t_newmethod)list2lists_new, - (t_method)list2lists_free, sizeof(t_list2lists), 0, A_GIMME, 0); + list2lists_class = class_new(gensym("list2lists"), + (t_newmethod)list2lists_new, + (t_method)list2lists_free, sizeof(t_list2lists), 0, A_GIMME, 0); class_addlist (list2lists_class, list2lists_list); - class_addmethod (list2lists_class, (t_method)list2lists_list2, gensym("lst2"), A_GIMME, 0); + class_addmethod (list2lists_class, (t_method)list2lists_list2, + gensym("lst2"), A_GIMME, 0); - class_addmethod(list2lists_class, (t_method)list2lists_help, gensym("help"), A_NULL); + class_addmethod(list2lists_class, (t_method)list2lists_help, + gensym("help"), A_NULL); zexy_register("list2lists"); } |