Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10458
Modified Files: Tag: desiredata desire.c Log Message: removed some MAXPDSTRING and some other fixed-size buffers
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.161 retrieving revision 1.1.2.217.2.162 diff -C2 -d -r1.1.2.217.2.161 -r1.1.2.217.2.162 *** desire.c 18 Jul 2007 16:12:15 -0000 1.1.2.217.2.161 --- desire.c 18 Jul 2007 16:33:34 -0000 1.1.2.217.2.162 *************** *** 27,30 **** --- 27,31 ---- #include <errno.h> #include <sys/time.h> + #include <sstream>
// oops, c99 only (is it standard C++ ?) *************** *** 63,67 **** #define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL)
- static void postatom2(const char *s, int argc, t_atom *argv); int imin(int a, int b) {return a<b?a:b;} int imax(int a, int b) {return a>b?a:b;} --- 64,67 ---- *************** *** 4644,4653 ****
void drawnumber_float(t_drawnumber *x, t_floatarg f) { - int viswas; if (x->vis.type != A_FLOAT || x->vis.var) { pd_error(x, "global vis/invis for a template with variable visibility"); return; } ! viswas = (x->vis.f != 0); if ((f != 0 && viswas) || (f == 0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); --- 4644,4652 ----
void drawnumber_float(t_drawnumber *x, t_floatarg f) { if (x->vis.type != A_FLOAT || x->vis.var) { pd_error(x, "global vis/invis for a template with variable visibility"); return; } ! int viswas = x->vis.f!=0; if ((f != 0 && viswas) || (f == 0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); *************** *** 4656,4669 **** }
! #define DRAWNUMBER_BUFSIZE 80 ! static void drawnumber_sprintf(t_drawnumber *x, char *buf, t_atom *ap) { ! strncpy(buf, x->label->name, DRAWNUMBER_BUFSIZE); ! buf[DRAWNUMBER_BUFSIZE - 1] = 0; ! int nchars = strlen(buf); ! atom_string(ap, buf + nchars, DRAWNUMBER_BUFSIZE - nchars); ! } ! ! static void drawnumber_vis(t_gobj *z, t_canvas *canvas, t_word *data, t_template *t, ! float basex, float basey, int vis) { t_drawnumber *x = (t_drawnumber *)z; if (!slot_getfloat(&x->vis, t, data, 0)) return; --- 4655,4659 ---- }
! static void drawnumber_vis(t_gobj *z, t_canvas *canvas, t_word *data, t_template *t, float basex, float basey, int vis) { t_drawnumber *x = (t_drawnumber *)z; if (!slot_getfloat(&x->vis, t, data, 0)) return; *************** *** 4672,4684 **** int xloc = canvas_xtopixels(canvas, basex + slot_getcoord(&x->xloc, t, data, 0)); int yloc = canvas_ytopixels(canvas, basey + slot_getcoord(&x->yloc, t, data, 0)); ! char colorstring[20], buf[DRAWNUMBER_BUFSIZE]; numbertocolor((int)slot_getfloat(&x->color, t, data, 1), colorstring); if (x->flags & DRAW_SYMBOL) SETSYMBOL(&at, slot_getsymbol(&x->value, t, data, 0)); else SETFLOAT( &at, slot_getfloat( &x->value, t, data, 0)); ! drawnumber_sprintf(x, buf, &at); sys_vgui(".x%lx.c create text %d %d -anchor nw -fill %s -text {%s}", ! (long)canvas_getcanvas(canvas), xloc, yloc, colorstring, buf); ! sys_vgui(" -font {Courier 42}"/*sys_hostfontsize(canvas_getfont(canvas))*/); ! sys_vgui(" -tags drawnumber%lx\n", (long)data); } else sys_vgui(".x%lx.c delete drawnumber%lx\n", (long)canvas_getcanvas(canvas), (long)data); } --- 4662,4675 ---- int xloc = canvas_xtopixels(canvas, basex + slot_getcoord(&x->xloc, t, data, 0)); int yloc = canvas_ytopixels(canvas, basey + slot_getcoord(&x->yloc, t, data, 0)); ! char colorstring[20]; numbertocolor((int)slot_getfloat(&x->color, t, data, 1), colorstring); if (x->flags & DRAW_SYMBOL) SETSYMBOL(&at, slot_getsymbol(&x->value, t, data, 0)); else SETFLOAT( &at, slot_getfloat( &x->value, t, data, 0)); ! std::ostringstream buf; ! buf << x->label->name; ! atom_ostream(&at,buf); sys_vgui(".x%lx.c create text %d %d -anchor nw -fill %s -text {%s}", ! (long)canvas_getcanvas(canvas), xloc, yloc, colorstring, buf.str().data()); ! sys_vgui(" -font {Courier 42} -tags drawnumber%lx\n", (long)data); /*sys_hostfontsize(canvas_getfont(canvas))*/ } else sys_vgui(".x%lx.c delete drawnumber%lx\n", (long)canvas_getcanvas(canvas), (long)data); } *************** *** 4695,4705 **** int firstkey; } dn; - - /* LATER protect against the template changing or the scalar disappearing - probably by attaching a gpointer here ... */ - - /* LATER protect against the template changing or the scalar disappearing - probably by attaching a gpointer here ... */
#if 0 static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy) { --- 4686,4691 ---- int firstkey; } dn;
+ /* LATER protect against the template changing or the scalar disappearing probably by attaching a gpointer here ... */ #if 0 static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy) { *************** *** 7292,7300 **** IGN("asiolatency"); startpost("%s: unknown message %s ", class_getname(pd_class(x)), s->name); ! for (int i = 0; i < argc; i++) { ! char str[80]; ! atom_string(argv+i, str, 80); ! poststring(str); ! } endpost(); } --- 7278,7284 ---- IGN("asiolatency"); startpost("%s: unknown message %s ", class_getname(pd_class(x)), s->name); ! std::ostringstream buf; ! for (int i = 0; i < argc; i++) {buf << " "; atom_ostream(argv+i,buf);} ! post("%s",buf.str().data()); endpost(); } *************** *** 7502,7515 ****
void postatom(int argc, t_atom *argv) { ! char buf[MAXPDSTRING]; ! for (int i=0; i<argc; i++) {atom_string(argv+i,buf,MAXPDSTRING); poststring(buf);} ! } ! ! static void postatom2(const char *s, int argc, t_atom *argv) { ! char buf[MAXPDSTRING]; ! FILE *f = stdout; ! fprintf(f,"%s",s); ! for (int i=0; i<argc; i++) {atom_string(argv+i,buf,MAXPDSTRING); fprintf(f,"%s ",buf);} ! fprintf(f,"\n"); }
--- 7486,7492 ----
void postatom(int argc, t_atom *argv) { ! std::ostringstream buf; ! for (int i=0; i<argc; i++) {buf << " "; atom_ostream(argv+i,buf);} ! dopost(buf.str().data()); }