From 739a8290a8b05645a2d055aed8e5eb76ba2e24e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Fri, 28 Aug 2015 17:55:26 +0000 Subject: one-true indentation svn path=/trunk/externals/zexy/; revision=17537 --- src/sort.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'src/sort.c') diff --git a/src/sort.c b/src/sort.c index 0850445..4bd92c0 100644 --- a/src/sort.c +++ b/src/sort.c @@ -1,4 +1,4 @@ -/* +/* * sort : sort a list of floats * * (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 . */ @@ -27,8 +27,7 @@ static t_class *sort_class; -typedef struct _sort -{ +typedef struct _sort { t_object x_obj; int bufsize; @@ -53,8 +52,12 @@ static void sort_buffer(t_sort *x, int argc, t_atom *argv) t_atom *atombuf = argv; if (argc != x->bufsize) { - if (x->buffer) freebytes(x->buffer, x->bufsize * sizeof(t_float)); - if (x->indices)freebytes(x->indices, x->bufsize * sizeof(t_int)); + if (x->buffer) { + freebytes(x->buffer, x->bufsize * sizeof(t_float)); + } + if (x->indices) { + freebytes(x->indices, x->bufsize * sizeof(t_int)); + } x->bufsize = argc; x->buffer = getbytes(x->bufsize * sizeof(t_float)); @@ -62,7 +65,7 @@ static void sort_buffer(t_sort *x, int argc, t_atom *argv) } buf = x->buffer; - while (n--){ + while (n--) { *buf++ = atom_getfloat(atombuf++); x->indices[n] = n; } @@ -101,17 +104,25 @@ static void sort_list(t_sort *x, t_symbol *s, int argc, t_atom *argv) } } - if (x->ascending) - for (n = 0; n < argc; n++) SETFLOAT(&atombuf[n], idx[n]); + if (x->ascending) + for (n = 0; n < argc; n++) { + SETFLOAT(&atombuf[n], idx[n]); + } else - for (n = 0, i=argc-1; n < argc; n++, i--) SETFLOAT(&atombuf[n], idx[i]); + for (n = 0, i=argc-1; n < argc; n++, i--) { + SETFLOAT(&atombuf[n], idx[i]); + } outlet_list(x->indexOut , gensym("list"), n, atombuf); - if (x->ascending) - for (n = 0; n < argc; n++) SETFLOAT(&atombuf[n], buf[n]); + if (x->ascending) + for (n = 0; n < argc; n++) { + SETFLOAT(&atombuf[n], buf[n]); + } else - for (n = 0, i=argc-1; n < argc; n++, i--) SETFLOAT(&atombuf[n], buf[i]); + for (n = 0, i=argc-1; n < argc; n++, i--) { + SETFLOAT(&atombuf[n], buf[i]); + } outlet_list(x->sortedOut, gensym("list"), n, atombuf); @@ -129,7 +140,8 @@ static void *sort_new(t_floatarg f) x->bufsize = 0; x->buffer = NULL; - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("direction")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), + gensym("direction")); return (x); } @@ -140,11 +152,12 @@ static void sort_help(t_sort*x) } void sort_setup(void) { - sort_class = class_new(gensym("sort"), (t_newmethod)sort_new, + sort_class = class_new(gensym("sort"), (t_newmethod)sort_new, 0, sizeof(t_sort), 0, A_DEFFLOAT, 0); - + class_addlist (sort_class, sort_list); - class_addmethod (sort_class, (t_method)sort_dir, gensym("direction"), A_DEFFLOAT, 0); + class_addmethod (sort_class, (t_method)sort_dir, gensym("direction"), + A_DEFFLOAT, 0); class_addmethod(sort_class, (t_method)sort_help, gensym("help"), A_NULL); zexy_register("sort"); -- cgit v1.2.1