Update of /cvsroot/pure-data/externals/zexy/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12596
Modified Files: fwriteln.c Log Message: added a format string for writing floats with fwriteln maybe a dangerous option....?
Index: fwriteln.c =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/fwriteln.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fwriteln.c 16 Aug 2007 22:23:41 -0000 1.4 --- fwriteln.c 21 Aug 2007 09:57:37 -0000 1.5 *************** *** 44,47 **** --- 44,48 ---- char *x_textbuf; char linebreak_chr[3]; + char format_string_afloats[20]; } t_fwriteln;
*************** *** 106,110 **** switch (argv->a_type) { case A_FLOAT: ! snprintf(text,MAXPDSTRING,"%.16g ", atom_getfloat(argv)); text[MAXPDSTRING-1]=0; length=strlen(text); --- 107,111 ---- switch (argv->a_type) { case A_FLOAT: ! snprintf(text,MAXPDSTRING,x->format_string_afloats, atom_getfloat(argv)); text[MAXPDSTRING-1]=0; length=strlen(text); *************** *** 169,173 **** }
! static void *fwriteln_new(void) { t_fwriteln *x = (t_fwriteln *)pd_new(fwriteln_class); --- 170,174 ---- }
! static void *fwriteln_new(t_symbol *s) { t_fwriteln *x = (t_fwriteln *)pd_new(fwriteln_class); *************** *** 175,178 **** --- 176,186 ---- x->x_file=0; x->x_textbuf=0; + if (s!=gensym("")) { + strcpy(x->format_string_afloats,s->s_name); + strcpy(x->format_string_afloats+strlen(s->s_name)," "); + } + else + strcpy(x->format_string_afloats,"%.16g "); + post("fwriteln: float format string "%s%"",x->format_string_afloats); return (void *)x; } *************** *** 181,185 **** { fwriteln_class = class_new(gensym("fwriteln"), (t_newmethod)fwriteln_new, ! (t_method) fwriteln_free, sizeof(t_fwriteln), 0, 0); class_addmethod(fwriteln_class, (t_method)fwriteln_open, gensym("open"), A_SYMBOL, A_DEFSYM, 0); class_addmethod(fwriteln_class, (t_method)fwriteln_close, gensym("close"), A_NULL, 0); --- 189,193 ---- { fwriteln_class = class_new(gensym("fwriteln"), (t_newmethod)fwriteln_new, ! (t_method) fwriteln_free, sizeof(t_fwriteln), CLASS_DEFAULT, A_DEFSYM, 0); class_addmethod(fwriteln_class, (t_method)fwriteln_open, gensym("open"), A_SYMBOL, A_DEFSYM, 0); class_addmethod(fwriteln_class, (t_method)fwriteln_close, gensym("close"), A_NULL, 0);