Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv314
Modified Files: Tag: desiredata desire.h desire.c kernel.c Log Message: introducing pd_eval_text
Index: kernel.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v retrieving revision 1.1.2.18 retrieving revision 1.1.2.19 diff -C2 -d -r1.1.2.18 -r1.1.2.19 *** kernel.c 31 Dec 2006 09:14:28 -0000 1.1.2.18 --- kernel.c 31 Dec 2006 16:39:17 -0000 1.1.2.19 *************** *** 1851,1865 **** }
void binbuf_text(t_binbuf *x, char *t, size_t size) { char *end=t+size; binbuf_clear(x); ! if (0) { ! while (t!=end) t=binbuf_text_matju(x,t,end); ! } else { ! while (t!=end) t=binbuf_text_miller(x,t,end); ! } binbuf_capa(x,x->n); }
/* convert a binbuf to text; no null termination. */ void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp) { --- 1851,1877 ---- }
+ int sys_syntax = 0; + void binbuf_text(t_binbuf *x, char *t, size_t size) { char *end=t+size; binbuf_clear(x); ! while (t!=end) t = sys_syntax ? binbuf_text_matju(x,t,end) : binbuf_text_miller(x,t,end); binbuf_capa(x,x->n); }
+ void pd_eval_text(char *t) { + t_binbuf *x = binbuf_new(); + char *end = t + strlen(t); + while (t!=end) { + t = sys_syntax ? binbuf_text_matju(x,t,end) : binbuf_text_miller(x,t,end); + if (x->n && x->vec[x->n-1].a_type == A_SEMI) { + fprintf(stderr,"pd_eval_text semi n=%d\n",x->n); + binbuf_eval(x,0,0,0); + binbuf_clear(x); + } + } + binbuf_free(x); + } + /* convert a binbuf to text; no null termination. */ void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp) { *************** *** 2256,2269 **** int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) { long length; - int fd; - int readret; char *buf; char namebuf[MAXPDSTRING]; if (*dirname) sprintf(namebuf,"%s/%s",dirname,filename); else sprintf(namebuf, "%s", filename); ! if ((fd = binbuf_doopen(namebuf, 0)) < 0) { ! error("open: %s: %s",namebuf,strerror(errno)); ! return 1; ! } if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0, SEEK_SET) < 0 || !(buf = (char *)t_getbytes(length))) { --- 2268,2277 ---- int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) { long length; char *buf; char namebuf[MAXPDSTRING]; if (*dirname) sprintf(namebuf,"%s/%s",dirname,filename); else sprintf(namebuf, "%s", filename); ! int fd = binbuf_doopen(namebuf, 0); ! if (fd < 0) {error("open: %s: %s",namebuf,strerror(errno)); return 1;} if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0, SEEK_SET) < 0 || !(buf = (char *)t_getbytes(length))) { *************** *** 2272,2276 **** return 1; } ! if ((readret = read(fd, buf, length)) < length) { error("read (%d %ld) -> %d; %s: %s\n", fd, length, readret, namebuf, strerror(errno)); close(fd); --- 2280,2285 ---- return 1; } ! int readret = read(fd, buf, length); ! if (readret < length) { error("read (%d %ld) -> %d; %s: %s\n", fd, length, readret, namebuf, strerror(errno)); close(fd); *************** *** 2278,2286 **** return 1; } ! /* optionally map carriage return to semicolon */ ! if (crflag) { ! int i; ! for (i = 0; i < length; i++) if (buf[i] == '\n') buf[i] = ';'; ! } binbuf_text(b, buf, length); t_freebytes(buf, length); --- 2287,2291 ---- return 1; } ! if (crflag) for (int i=0; i<length; i++) if (buf[i]=='\n') buf[i] = ';'; binbuf_text(b, buf, length); t_freebytes(buf, length); *************** *** 2289,2312 **** }
! /* read a binbuf from a file, via the search patch of a canvas */ int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int crflag) { - int filedesc; char buf[MAXPDSTRING], *bufptr; ! if ((filedesc = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 0)) < 0) { ! error("%s: can't open", filename); ! return 1; ! } else close(filedesc); return !!binbuf_read(b, bufptr, buf, crflag); }
! /* old version */ int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, int crflag) { - int filedesc; char buf[MAXPDSTRING], *bufptr; ! if ((filedesc = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0)) < 0) { ! error("%s: can't open", filename); ! return 1; ! } ! else close (filedesc); return !!binbuf_read(b, bufptr, buf, crflag); } --- 2294,2312 ---- }
! /* read a binbuf from a file, via the search patch of a canvas */ int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int crflag) { char buf[MAXPDSTRING], *bufptr; ! int filedesc = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 0); ! if (filedesc<0) {error("%s: can't open", filename); return 1;} ! close(filedesc); return !!binbuf_read(b, bufptr, buf, crflag); }
! /* old version */ int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, int crflag) { char buf[MAXPDSTRING], *bufptr; ! int filedesc = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0); ! if (filedesc<0) {error("%s: can't open", filename); return 1;} ! close(filedesc); return !!binbuf_read(b, bufptr, buf, crflag); }
Index: desire.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.h,v retrieving revision 1.1.2.49.2.19 retrieving revision 1.1.2.49.2.20 diff -C2 -d -r1.1.2.49.2.19 -r1.1.2.49.2.20 *** desire.h 31 Dec 2006 07:26:33 -0000 1.1.2.49.2.19 --- desire.h 31 Dec 2006 16:39:15 -0000 1.1.2.49.2.20 *************** *** 266,271 **** #define PLOTSTYLE_BEZ 2
! /* from m_pd.c */ EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
/* from desire.c */ --- 266,273 ---- #define PLOTSTYLE_BEZ 2
! /* from kernel.c */ EXTERN void gobj_save(t_gobj *x, t_binbuf *b); + EXTERN void pd_eval_text(char *t); + EXTERN int sys_syntax;
/* from desire.c */
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.98 retrieving revision 1.1.2.217.2.99 diff -C2 -d -r1.1.2.217.2.98 -r1.1.2.217.2.99 *** desire.c 31 Dec 2006 08:05:55 -0000 1.1.2.217.2.98 --- desire.c 31 Dec 2006 16:39:15 -0000 1.1.2.217.2.99 *************** *** 1437,1450 ****
static t_pd *garray_arraytemplatecanvas; - static char garray_arraytemplatefile[] = "\ - #N canvas 0 0 458 153 10;\n\ - #X obj 43 31 struct _float_array array z float float style\n\ - float linewidth float color;\n\ - #X obj 43 70 plot z color linewidth 0 0 1 style;\n\ - "; - static char garray_floattemplatefile[] = "\ - #N canvas 0 0 458 153 10;\n\ - #X obj 39 26 struct float float y;\n\ - ";
/* create invisible, built-in canvases to determine the templates for floats --- 1437,1440 ---- *************** *** 1456,1465 **** t_binbuf *b = binbuf_new(); glob_setfilename(0, gensym("_float"), gensym(".")); ! binbuf_text(b, garray_floattemplatefile, strlen(garray_floattemplatefile)); ! binbuf_eval(b, 0, 0, 0); vmess(s__X.s_thing, gensym("pop"), "i", 0); glob_setfilename(0, gensym("_float_array"), gensym(".")); ! binbuf_text(b, garray_arraytemplatefile, strlen(garray_arraytemplatefile)); ! binbuf_eval(b, 0, 0, 0); garray_arraytemplatecanvas = s__X.s_thing; vmess(s__X.s_thing, gensym("pop"), "i", 0); --- 1446,1458 ---- t_binbuf *b = binbuf_new(); glob_setfilename(0, gensym("_float"), gensym(".")); ! pd_eval_text( ! "#N canvas 0 0 458 153 10;\n" ! "#X obj 43 31 struct _float_array array z float float style float linewidth float color;\n" ! "#X obj 43 70 plot z color linewidth 0 0 1 style;\n"); vmess(s__X.s_thing, gensym("pop"), "i", 0); glob_setfilename(0, gensym("_float_array"), gensym(".")); ! pd_eval_text( ! "#N canvas 0 0 458 153 10;\n" ! "#X obj 39 26 struct float float y;\n"); garray_arraytemplatecanvas = s__X.s_thing; vmess(s__X.s_thing, gensym("pop"), "i", 0); *************** *** 6476,6479 **** --- 6469,6473 ---- binbuf_addv(b, "ttii", "#X","restore", (t_int)x->x, (t_int)x->y); if (x->binbuf) { + pd_print(x,"pd_upload"); binbuf_addbinbuf(b, x->binbuf); } else {