Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24566
Modified Files: Tag: desiredata m_pd.h desire.c Log Message: removed some MAXPDSTRING, including a no-size-limit mode to canvas_makefilename
Index: m_pd.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v retrieving revision 1.4.4.11.2.33.2.53 retrieving revision 1.4.4.11.2.33.2.54 diff -C2 -d -r1.4.4.11.2.33.2.53 -r1.4.4.11.2.33.2.54 *** m_pd.h 18 Jul 2007 16:12:18 -0000 1.4.4.11.2.33.2.53 --- m_pd.h 18 Jul 2007 18:36:52 -0000 1.4.4.11.2.33.2.54 *************** *** 460,464 **** EXTERN t_symbol *canvas_getcurrentdir(void); EXTERN t_glist *canvas_getcurrent(void); ! EXTERN void canvas_makefilename(t_glist *c, char *file, char *result, int resultsize); EXTERN t_symbol *canvas_getdir(t_glist *x); EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b); --- 460,465 ---- EXTERN t_symbol *canvas_getcurrentdir(void); EXTERN t_glist *canvas_getcurrent(void); ! /* if result==0 then it will allocate a result and return it */ ! EXTERN char *canvas_makefilename(t_glist *c, char *file, char *result, int resultsize); EXTERN t_symbol *canvas_getdir(t_glist *x); EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b);
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.163 retrieving revision 1.1.2.217.2.164 diff -C2 -d -r1.1.2.217.2.163 -r1.1.2.217.2.164 *** desire.c 18 Jul 2007 18:11:40 -0000 1.1.2.217.2.163 --- desire.c 18 Jul 2007 18:36:52 -0000 1.1.2.217.2.164 *************** *** 417,435 **** t_symbol *canvas_getdir(t_canvas *x) {return canvas_getenv( x)->dir;}
! void canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize) { char *dir = canvas_getenv(x)->dir->name; if (file[0] == '/' || (file[0] && file[1] == ':') || !*dir) { strncpy(result, file, resultsize); result[resultsize-1] = 0; } else { ! int nleft; ! strncpy(result, dir, resultsize); ! result[resultsize-1] = 0; ! nleft = resultsize - strlen(result) - 1; ! if (nleft <= 0) return; ! strcat(result, "/"); ! strncat(result, file, nleft); ! result[resultsize-1] = 0; } }
--- 417,431 ---- t_symbol *canvas_getdir(t_canvas *x) {return canvas_getenv( x)->dir;}
! char *canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize) { char *dir = canvas_getenv(x)->dir->name; if (file[0] == '/' || (file[0] && file[1] == ':') || !*dir) { + if (!result) return strdup(file); strncpy(result, file, resultsize); result[resultsize-1] = 0; } else { ! if (result) {snprintf(result,resultsize,"%s/%s",dir,file); result[resultsize-1] = 0;} ! else asprintf(&result, "%s/%s",dir,file); } + return result; }
*************** *** 2008,2022 ****
static void garray_write(t_garray *x, t_symbol *filename) { - char buf[MAXPDSTRING]; int yonset, elemsize; t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); TEMPLATE_FLOATY(x,array,) ! canvas_makefilename(canvas_getcanvas(x->canvas), filename->name, buf, MAXPDSTRING); sys_bashfilename(buf, buf); FILE *fd = fopen(buf, "w"); if (!fd) { pd_error(x,"can't create file '%s'", buf); return; } for (int i=0; i < array->n; i++) { if (fprintf(fd, "%g\n", *(float *)(((array->vec + sizeof(t_word) * i)) + yonset)) < 1) { --- 2004,2019 ----
static void garray_write(t_garray *x, t_symbol *filename) { int yonset, elemsize; t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); TEMPLATE_FLOATY(x,array,) ! char *buf = canvas_makefilename(canvas_getcanvas(x->canvas),filename->name,0,0); sys_bashfilename(buf, buf); FILE *fd = fopen(buf, "w"); if (!fd) { pd_error(x,"can't create file '%s'", buf); + free(buf); return; } + free(buf); for (int i=0; i < array->n; i++) { if (fprintf(fd, "%g\n", *(float *)(((array->vec + sizeof(t_word) * i)) + yonset)) < 1) { *************** *** 2804,2810 ****
static void canvas_write(t_canvas *x, t_symbol *filename, t_symbol *format) { - char buf[MAXPDSTRING]; t_canvas *canvas = canvas_getcanvas(x); ! canvas_makefilename(canvas, filename->name, buf, MAXPDSTRING); int cr = strcmp(format->name, "cr")==0; if (!cr && *format->name) pd_error(x,"canvas_write: unknown flag: %s", format->name); --- 2801,2806 ----
static void canvas_write(t_canvas *x, t_symbol *filename, t_symbol *format) { t_canvas *canvas = canvas_getcanvas(x); ! char *buf = canvas_makefilename(canvas,filename->name,0,0); int cr = strcmp(format->name, "cr")==0; if (!cr && *format->name) pd_error(x,"canvas_write: unknown flag: %s", format->name); *************** *** 2814,2817 **** --- 2810,2814 ---- binbuf_free(b); } + free(buf); }
*************** *** 4702,4710 ****
static void drawnumber_key(void *z, t_floatarg fkey) { ! t_drawnumber *x = (t_drawnumber *)z; ! t_slot *f = &x->value; int key = (int)fkey; - char sbuf[MAXPDSTRING]; - t_atom at; if (!gpointer_check(&dn.gpointer, 0)) { post("drawnumber_motion: scalar disappeared"); --- 4699,4704 ----
static void drawnumber_key(void *z, t_floatarg fkey) { ! //t_drawnumber *x = (t_drawnumber *)z; int key = (int)fkey; if (!gpointer_check(&dn.gpointer, 0)) { post("drawnumber_motion: scalar disappeared"); *************** *** 4713,4742 **** if (key == 0) return; if (dn.symbol) { ! /* key entry for a symbol field */ ! if (dn.firstkey) sbuf[0] = 0; ! else strncpy(sbuf, template_getsymbol(dn.t, f->varsym, dn.wp, 1)->name, MAXPDSTRING); ! sbuf[MAXPDSTRING-1] = 0; ! if (key == '\b') { ! if (*sbuf) sbuf[strlen(sbuf)-1] = 0; ! } else { ! sbuf[strlen(sbuf)+1] = 0; ! sbuf[strlen(sbuf)] = key; ! } } else { ! /* key entry for a numeric field. This is just a stopgap. */ ! if (dn.firstkey) sbuf[0] = 0; ! else sprintf(sbuf, "%g", template_getfloat(dn.t, f->varsym, dn.wp, 1)); ! dn.firstkey = (key == '\n'); ! if (key == '\b') { ! if (*sbuf) sbuf[strlen(sbuf)-1] = 0; ! } else { ! sbuf[strlen(sbuf)+1] = 0; ! sbuf[strlen(sbuf)] = key; ! } ! float newf; ! if (sscanf(sbuf, "%g", &newf) < 1) newf = 0; ! template_setfloat(dn.t, f->varsym, dn.wp, newf, 1); ! if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at); ! if (dn.scalar) gobj_changed(dn.scalar,0); else gobj_changed(dn.array,0); } } --- 4707,4721 ---- if (key == 0) return; if (dn.symbol) { ! /* key entry for a symbol field... has to be rewritten in Tcl similarly to TextBox for edition of [drawsymbol] */ ! // template_getsymbol(dn.t, f->varsym, dn.wp, 1)->name; } else { ! /* key entry for a numeric field... same here... [drawnumber] */ ! //t_slot *f = &x->value; ! //float newf; ! //if (sscanf(sbuf, "%g", &newf) < 1) newf = 0; ! //template_setfloat(dn.t, f->varsym, dn.wp, newf, 1); ! //t_atom at; ! //if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at); ! //if (dn.scalar) gobj_changed(dn.scalar,0); else gobj_changed(dn.array,0); } }