[PD-cvs] pd/src kernel.c,1.1.2.67,1.1.2.68

Mathieu Bouchard matju at users.sourceforge.net
Fri Jul 20 06:22:18 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18877

Modified Files:
      Tag: desiredata
	kernel.c 
Log Message:
removed some MAXPDSTRING


Index: kernel.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v
retrieving revision 1.1.2.67
retrieving revision 1.1.2.68
diff -C2 -d -r1.1.2.67 -r1.1.2.68
*** kernel.c	19 Jul 2007 23:22:17 -0000	1.1.2.67
--- kernel.c	20 Jul 2007 04:22:16 -0000	1.1.2.68
***************
*** 2087,2091 ****
  }
  
! static FILE *binbuf_dofopen(char *s, char *mode) {
      char namebuf[strlen(s)+1];
      sys_bashfilename(s, namebuf);
--- 2087,2091 ----
  }
  
! static FILE *binbuf_dofopen(const char *s, char *mode) {
      char namebuf[strlen(s)+1];
      sys_bashfilename(s, namebuf);
***************
*** 2129,2137 ****
  /* old version */
  int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, int flags) {
!     char buf[MAXPDSTRING], *bufptr;
!     int fd = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0);
      if (fd<0) {error("%s: can't open", filename); return 1;}
      close(fd);
!     return !!binbuf_read(b, bufptr, buf, flags);
  }
  
--- 2129,2139 ----
  /* old version */
  int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, int flags) {
!     char *buf, *bufptr;
!     int fd = open_via_path2(dirname, filename, "", &buf, &bufptr, 0);
      if (fd<0) {error("%s: can't open", filename); return 1;}
      close(fd);
!     bool r = binbuf_read(b, bufptr, buf, flags);
!     free(buf);
!     return r;
  }
  
***************
*** 2141,2174 ****
  /* write a binbuf to a text file.  If "crflag" is set we suppress semicolons. */
  int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag) {
!     FILE *f = 0;
!     char sbuf[WBUFSIZE], fbuf[MAXPDSTRING], *bp = sbuf, *ep = sbuf + WBUFSIZE;
!     t_atom *ap;
!     int indx, deleteit = 0;
      int ncolumn = 0;
! 
!     fbuf[0] = 0;
!     if (*dir)
!         strcat(fbuf, dir), strcat(fbuf, "/");
!     strcat(fbuf, filename);
      if (!strcmp(filename + strlen(filename) - 4, ".pat")) {
          x = binbuf_convert(x, 0);
          deleteit = 1;
      }
!     if (!(f = binbuf_dofopen(fbuf, "w"))) {
!         error("open: %s: %s",fbuf,strerror(errno));
!         goto fail;
!     }
!     for (ap = x->v, indx = x->n; indx--; ap++) {
!         int length;
!             /* estimate how many characters will be needed.  Printing out
!             symbols may need extra characters for inserting backslashes. */
!         if (ap->a_type == A_SYMBOL || ap->a_type == A_DOLLSYM)
!             length = 80 + strlen(ap->a_symbol->name);
!         else length = 40;
          if (ep - bp < length) {
!             if (fwrite(sbuf, bp-sbuf, 1, f) < 1) {
!                 error("write: %s: %s",fbuf,strerror(errno));
!                 goto fail;
!             }
              bp = sbuf;
          }
--- 2143,2165 ----
  /* write a binbuf to a text file.  If "crflag" is set we suppress semicolons. */
  int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag) {
!     char sbuf[WBUFSIZE];
!     ostringstream fbuf;
!     char *bp = sbuf, *ep = sbuf + WBUFSIZE;
!     int indx; bool deleteit = 0;
      int ncolumn = 0;
!     if (*dir) fbuf << dir << "/";
!     fbuf << filename;
      if (!strcmp(filename + strlen(filename) - 4, ".pat")) {
          x = binbuf_convert(x, 0);
          deleteit = 1;
      }
!     FILE *f = binbuf_dofopen(fbuf.str().data(), "w");
!     if (!f) {error("open: %s: %s",fbuf.str().data(),strerror(errno)); goto fail;}
!     indx = x->n;
!     for (t_atom *ap = x->v; indx--; ap++) {
!         /* estimate how many characters will be needed.  Printing out symbols may need extra characters for inserting backslashes. */
!         int length = (ap->a_type == A_SYMBOL || ap->a_type == A_DOLLSYM) ? 80 + strlen(ap->a_symbol->name) : 40;
          if (ep - bp < length) {
!             if (fwrite(sbuf, bp-sbuf, 1, f) < 1) {error("write: %s: %s",fbuf.str().data(),strerror(errno)); goto fail;}
              bp = sbuf;
          }
***************
*** 2188,2195 ****
          }
      }
!     if (fwrite(sbuf, bp-sbuf, 1, f) < 1) {
!         error("write: %s: %s",fbuf,strerror(errno));
!         goto fail;
!     }
      if (deleteit) binbuf_free(x);
      fclose(f);
--- 2179,2183 ----
          }
      }
!     if (fwrite(sbuf, bp-sbuf, 1, f) < 1) {error("write: %s: %s",fbuf.str().data(),strerror(errno)); goto fail;}
      if (deleteit) binbuf_free(x);
      fclose(f);
***************
*** 2204,2208 ****
     but you will need to make lots of abstractions for objects like "gate" which don't exist in Pd. Conversion
     from Pd to Max hasn't been tested for patches with subpatches yet!  */
- 
  #define MAXSTACK 1000
  #define ISSYMBOL(a, b) ((a)->a_type == A_SYMBOL && !strcmp((a)->a_symbol->name, (b)))
--- 2192,2195 ----





More information about the Pd-cvs mailing list