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/makesymbol.c | 134 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 64 deletions(-) (limited to 'src/makesymbol.c') diff --git a/src/makesymbol.c b/src/makesymbol.c index f0342d8..bc24749 100644 --- a/src/makesymbol.c +++ b/src/makesymbol.c @@ -1,4 +1,4 @@ -/* +/* * makesymbol: yet another (formatted) symbol creation mechanism * * (c) 1999-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem) @@ -7,29 +7,29 @@ * 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 . */ -/* +/* (l) 1210:forum::für::umläute:1999 -"makesymbol" is something between "symbol" and "makefilename", +"makesymbol" is something between "symbol" and "makefilename", thus storing and creating (formatted) symbols... TODO: - the use of only "%s" is really not very satisfying - LATER: - split the entire format string into subformats with only + the use of only "%s" is really not very satisfying + LATER: + split the entire format string into subformats with only one format-placeholder ("%[^%]*[diufFgGxXoscpn]") . split the entire format string into subformats with only one format-placeholder, store the types @@ -49,24 +49,23 @@ static t_class *makesymbol_class; -typedef struct _makesymbol -{ - t_object x_obj; - t_symbol *x_sym; +typedef struct _makesymbol { + t_object x_obj; + t_symbol *x_sym; - char* mask; - char* buf; + char* mask; + char* buf; } t_makesymbol; static void reset_mask(t_makesymbol *x, t_symbol *s) { - if (*s->s_name) { - x->mask = s->s_name; - x->x_sym = s; - } else { - x->mask = "%s%s%s%s%s%s%s%s%s%s"; - x->x_sym = gensym(""); - } + if (*s->s_name) { + x->mask = s->s_name; + x->x_sym = s; + } else { + x->mask = "%s%s%s%s%s%s%s%s%s%s"; + x->x_sym = gensym(""); + } } typedef char cstring[MAXSTRINGLENG]; @@ -74,85 +73,92 @@ typedef char cstring[MAXSTRINGLENG]; static t_symbol* list2symbol(char *masque, int argc, t_atom *argv) { cstring*buf=(cstring*)getbytes(MAXSTRINGARGS*sizeof(cstring)); - cstring buffer; - int i; + cstring buffer; + int i; - for(i=0; ix_sym = list2symbol(x->mask, argc, argv); - outlet_symbol(x->x_obj.ob_outlet, x->x_sym); + x->x_sym = list2symbol(x->mask, argc, argv); + outlet_symbol(x->x_obj.ob_outlet, x->x_sym); } static void makesymbol_bang(t_makesymbol *x) { - outlet_symbol(x->x_obj.ob_outlet, x->x_sym); + outlet_symbol(x->x_obj.ob_outlet, x->x_sym); } static void *makesymbol_new(t_symbol* UNUSED(s), int argc, t_atom *argv) { - t_makesymbol *x = (t_makesymbol *)pd_new(makesymbol_class); + t_makesymbol *x = (t_makesymbol *)pd_new(makesymbol_class); - x->buf = (char *)getbytes(MAXSTRINGLENG * sizeof(char)); + x->buf = (char *)getbytes(MAXSTRINGLENG * sizeof(char)); - x->mask = x->buf; + x->mask = x->buf; - if (argc) { - atom_string(argv, x->buf, MAXSTRINGLENG); - x->x_sym = gensym(x->buf); - } else { - x->mask = "%s%s%s%s%s%s%s%s%s%s"; - x->x_sym = gensym(""); - } + if (argc) { + atom_string(argv, x->buf, MAXSTRINGLENG); + x->x_sym = gensym(x->buf); + } else { + x->mask = "%s%s%s%s%s%s%s%s%s%s"; + x->x_sym = gensym(""); + } - outlet_new(&x->x_obj, gensym("symbol")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("symbol"), gensym("sym1")); + outlet_new(&x->x_obj, gensym("symbol")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("symbol"), gensym("sym1")); - return (x); + return (x); } static void makesymbol_free(t_makesymbol *x) { - freebytes(x->buf, MAXSTRINGLENG*sizeof(char)); + freebytes(x->buf, MAXSTRINGLENG*sizeof(char)); } static void makesymbol_helper(t_makesymbol* UNUSED(x)) { - post("\n"HEARTSYMBOL" makesymbol :: create a formatted symbol"); - post("\t: glue up to 10 list-elements to 1 formatted symbol\n" - "'bang'\t\t\t: re-output\n" - "'help'\t\t\t: view this" - "\ninlet2 : : new format-string (symbol !)" - "\noutlet : \t: formatted concatenation"); - post("\ncreation:\"makesymbol []\": C-style format-string (%s only)", "%s"); + post("\n"HEARTSYMBOL" makesymbol :: create a formatted symbol"); + post("\t: glue up to 10 list-elements to 1 formatted symbol\n" + "'bang'\t\t\t: re-output\n" + "'help'\t\t\t: view this" + "\ninlet2 : : new format-string (symbol !)" + "\noutlet : \t: formatted concatenation"); + post("\ncreation:\"makesymbol []\": C-style format-string (%s only)", + "%s"); } void makesymbol_setup(void) { - makesymbol_class = class_new(gensym("makesymbol"), - (t_newmethod)makesymbol_new, (t_method)makesymbol_free, - sizeof(t_makesymbol), 0, A_GIMME, 0); + makesymbol_class = class_new(gensym("makesymbol"), + (t_newmethod)makesymbol_new, (t_method)makesymbol_free, + sizeof(t_makesymbol), 0, A_GIMME, 0); - class_addlist(makesymbol_class, makesymbol_list); - class_addbang(makesymbol_class, makesymbol_bang); + class_addlist(makesymbol_class, makesymbol_list); + class_addbang(makesymbol_class, makesymbol_bang); - class_addmethod(makesymbol_class, (t_method)reset_mask, gensym("sym1"), A_SYMBOL, 0); + class_addmethod(makesymbol_class, (t_method)reset_mask, gensym("sym1"), + A_SYMBOL, 0); - class_addmethod(makesymbol_class, (t_method)makesymbol_helper, gensym("help"), 0); + class_addmethod(makesymbol_class, (t_method)makesymbol_helper, + gensym("help"), 0); zexy_register("makesymbol"); } -- cgit v1.2.1