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/symbol2list.c | 93 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 39 deletions(-) (limited to 'src/symbol2list.c') diff --git a/src/symbol2list.c b/src/symbol2list.c index 5d7e74a..5c49481 100644 --- a/src/symbol2list.c +++ b/src/symbol2list.c @@ -1,4 +1,4 @@ -/* +/* * symbol2list: convert a symbol into a list (with given delimiters) * * (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 . */ @@ -25,19 +25,21 @@ static t_class *symbol2list_class; -typedef struct _symbol2list -{ +typedef struct _symbol2list { t_object x_obj; t_symbol *s, *delimiter; t_atom *argv; - int argc, argnum; /* "argnum" is the number of reserved atoms (might be >argc) */ + int argc, + argnum; /* "argnum" is the number of reserved atoms (might be >argc) */ } t_symbol2list; -static void symbol2list_delimiter(t_symbol2list *x, t_symbol *s){ +static void symbol2list_delimiter(t_symbol2list *x, t_symbol *s) +{ x->delimiter = s; } -STATIC_INLINE void string2atom(t_atom *ap, char* cp, int clen){ +STATIC_INLINE void string2atom(t_atom *ap, char* cp, int clen) +{ char *buffer=getbytes(sizeof(char)*(clen+1)); char *endptr[1]; t_float ftest; @@ -49,9 +51,9 @@ STATIC_INLINE void string2atom(t_atom *ap, char* cp, int clen){ * symbol "hallo 0x12" will become "list hallo 18" * do we want this ?? */ - if (buffer+clen!=*endptr){ + if (buffer+clen!=*endptr) { /* strtof() failed, we have a symbol */ - SETSYMBOL(ap, gensym(buffer)); + SETSYMBOL(ap, gensym(buffer)); } else { /* it is a number. */ SETFLOAT(ap,ftest); @@ -66,39 +68,41 @@ static void symbol2list_process(t_symbol2list *x) char *cp, *d; int i=1; - if (x->s==NULL){ + if (x->s==NULL) { x->argc=0; return; } cc=x->s->s_name; cp=cc; - - if (x->delimiter==NULL || x->delimiter==gensym("")){ + + if (x->delimiter==NULL || x->delimiter==gensym("")) { i=strlen(cc); - if(x->argnumargnumargv, x->argnum*sizeof(t_atom)); x->argnum=i+10; x->argv=getbytes(x->argnum*sizeof(t_atom)); } x->argc=i; - while(i--)string2atom(x->argv+i, cc+i, 1); + while(i--) { + string2atom(x->argv+i, cc+i, 1); + } return; } deli=x->delimiter->s_name; dell=strlen(deli); - + /* get the number of tokens */ - while((d=strstr(cp, deli))){ - if (d!=NULL && d!=cp){ + while((d=strstr(cp, deli))) { + if (d!=NULL && d!=cp) { i++; } cp=d+dell; } /* resize the list-buffer if necessary */ - if(x->argnumargnumargv, x->argnum*sizeof(t_atom)); x->argnum=i+10; x->argv=getbytes(x->argnum*sizeof(t_atom)); @@ -106,29 +110,37 @@ static void symbol2list_process(t_symbol2list *x) x->argc=i; /* parse the tokens into the list-buffer */ i=0; - - /* find the first token */ - cp=cc; - while(cp==(d=strstr(cp,deli))){cp+=dell;} - while((d=strstr(cp, deli))){ - if(d!=cp){ - string2atom(x->argv+i, cp, d-cp); - i++; - } - cp=d+dell; + + /* find the first token */ + cp=cc; + while(cp==(d=strstr(cp,deli))) { + cp+=dell; + } + while((d=strstr(cp, deli))) { + if(d!=cp) { + string2atom(x->argv+i, cp, d-cp); + i++; } + cp=d+dell; + } - if(cp)string2atom(x->argv+i, cp, strlen(cp)); + if(cp) { + string2atom(x->argv+i, cp, strlen(cp)); + } } -static void symbol2list_bang(t_symbol2list *x){ - if(!(x->s) || x->s==gensym("")){ +static void symbol2list_bang(t_symbol2list *x) +{ + if(!(x->s) || x->s==gensym("")) { outlet_bang(x->x_obj.ob_outlet); return; } symbol2list_process(x); - if(x->argc)outlet_list(x->x_obj.ob_outlet, 0, x->argc, x->argv); + if(x->argc) { + outlet_list(x->x_obj.ob_outlet, 0, x->argc, x->argv); + } } -static void symbol2list_symbol(t_symbol2list *x, t_symbol *s){ +static void symbol2list_symbol(t_symbol2list *x, t_symbol *s) +{ x->s = s; symbol2list_bang(x); } @@ -143,7 +155,7 @@ static void *symbol2list_new(t_symbol* UNUSED(s), int argc, t_atom *argv) x->argnum=16; x->argv=getbytes(x->argnum*sizeof(t_atom)); symbol2list_delimiter(x, (argc)?atom_getsymbol(argv):gensym(" ")); - + return (x); } @@ -157,14 +169,17 @@ static void symbol2list_help(t_symbol2list*x) void symbol2list_setup(void) { - symbol2list_class = class_new(gensym("symbol2list"), (t_newmethod)symbol2list_new, - (t_method)symbol2list_free, sizeof(t_symbol2list), 0, A_GIMME, 0); + symbol2list_class = class_new(gensym("symbol2list"), + (t_newmethod)symbol2list_new, + (t_method)symbol2list_free, sizeof(t_symbol2list), 0, A_GIMME, 0); class_addcreator((t_newmethod)symbol2list_new, gensym("s2l"), A_GIMME, 0); class_addsymbol (symbol2list_class, symbol2list_symbol); class_addbang (symbol2list_class, symbol2list_bang); - class_addmethod (symbol2list_class, (t_method)symbol2list_delimiter, gensym(""), A_SYMBOL, 0); - class_addmethod(symbol2list_class, (t_method)symbol2list_help, gensym("help"), A_NULL); + class_addmethod (symbol2list_class, (t_method)symbol2list_delimiter, + gensym(""), A_SYMBOL, 0); + class_addmethod(symbol2list_class, (t_method)symbol2list_help, + gensym("help"), A_NULL); zexy_register("symbol2list"); } -- cgit v1.2.1