[PD-cvs] externals/zexy/src msgfile.c,1.10,1.11

IOhannes m zmölnig zmoelnig at users.sourceforge.net
Wed Jun 7 17:24:40 CEST 2006


Update of /cvsroot/pure-data/externals/zexy/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14408/src

Modified Files:
	msgfile.c 
Log Message:
hopefully fixed a bug discovered by p8r: 1st line was not read (or rather "output"); i guess this has more to do withpd>0=0.39 but you never no...;
 more testing needs to be done!

Index: msgfile.c
===================================================================
RCS file: /cvsroot/pure-data/externals/zexy/src/msgfile.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** msgfile.c	5 Apr 2006 11:27:26 -0000	1.10
--- msgfile.c	7 Jun 2006 15:24:37 -0000	1.11
***************
*** 96,100 ****
    
    t_msglist *cur=x->current;
! 
    if (cur) {
      t_atom *ap;
--- 96,103 ----
    
    t_msglist *cur=x->current;
!   if(ac&&av&&A_SYMBOL==av->a_type&&gensym("")==atom_getsymbol(av)){
!     /* ignoring empty symbols! */
!     return;
!   }
    if (cur) {
      t_atom *ap;
***************
*** 235,239 ****
  
    msgfile_goto(x, i);
- 
  }
  
--- 238,241 ----
***************
*** 521,527 ****
  
    int fd;
!   long readlength, length;
    char filnam[MAXPDSTRING], namebuf[MAXPDSTRING];
    char buf[MAXPDSTRING], *bufptr, *readbuf;
    char*dirname=canvas_getdir(x->x_canvas)->s_name;
  
--- 523,530 ----
  
    int fd;
!   long readlength, length, pos;
    char filnam[MAXPDSTRING], namebuf[MAXPDSTRING];
    char buf[MAXPDSTRING], *bufptr, *readbuf;
+   char *charbinbuf=NULL, *cbb;
    char*dirname=canvas_getdir(x->x_canvas)->s_name;
  
***************
*** 543,561 ****
        return;
      }
-   } else {
-     close (fd);
- 
-     namebuf[0] = 0;
-     if (*buf)
-       strcat(namebuf, buf), strcat(namebuf, "/");
-     strcat(namebuf, bufptr);
-     
-     /* open and get length */
-     sys_bashfilename(namebuf, filnam);
-     
-     if ((fd = open(filnam, rmode)) < 0) {
-       error("msgfile_read: unable to open %s", filnam);
-       return;
-     }
    }
  
--- 546,549 ----
***************
*** 572,576 ****
    case CR_MODE:
      separator = ' ';
!     eol = ' ';
      break;
    case CSV_MODE:
--- 560,564 ----
    case CR_MODE:
      separator = ' ';
!     eol = '\n';
      break;
    case CSV_MODE:
***************
*** 579,583 ****
      break;
    default:
!     separator = ' ';
      eol = ';';
      break;
--- 567,571 ----
      break;
    default:
!     separator = '\n';
      eol = ';';
      break;
***************
*** 602,623 ****
    close(fd);
  
!   /* undo separators and eols */
    bufptr=readbuf;
  
    while (readlength--) {
      if (*bufptr == separator) {
!       *bufptr = ' ';
      }
!     else if ((*bufptr == eol) && (bufptr[1] == '\n')) *bufptr = ';';
      bufptr++;
    }
! 
    /* convert to binbuf */
!   binbuf_text(bbuf, readbuf, length);
    msgfile_binbuf2listbuf(x, bbuf);
  
! 
    binbuf_free(bbuf);
    t_freebytes(readbuf, length);
  }
  
--- 590,640 ----
    close(fd);
  
!   /* convert separators and eols to what pd expects in a binbuf*/
    bufptr=readbuf;
  
+ # define MSGFILE_HEADROOM 1024
+ 
+   charbinbuf=(char*)getbytes(length+MSGFILE_HEADROOM);
+   cbb=charbinbuf;
+   for(pos=0; pos<length+MSGFILE_HEADROOM; pos++)charbinbuf[pos]=0;
+ 
+   *cbb++=';';
+   pos=1;
    while (readlength--) {
+     if(pos>=length+MSGFILE_HEADROOM){
+       error("msgfile: read error (headroom %d too small!)", MSGFILE_HEADROOM);
+       goto read_error;
+       break;
+     }
      if (*bufptr == separator) {
!       *cbb = ' ';
!     } else if (*bufptr==eol) {
!       *cbb++=';';pos++;
!       *cbb='\n';
      }
!     else {
!       *cbb=*bufptr;
!     }
! 
      bufptr++;
+     cbb++;
+     pos++;
    }
! #if 0
!   //  if(';'==cbb[-1])cbb[-1]=0;
!   pos--;
!   while(pos>0&&('\n'==charbinbuf[pos]||';'==charbinbuf[pos]||' '==charbinbuf[pos])){
!     charbinbuf[pos]=0;
!     pos--;
!   }
! #endif
    /* convert to binbuf */
!   binbuf_text(bbuf, charbinbuf, length+MSGFILE_HEADROOM);
    msgfile_binbuf2listbuf(x, bbuf);
  
!  read_error:
    binbuf_free(bbuf);
    t_freebytes(readbuf, length);
+   t_freebytes(charbinbuf, length+MSGFILE_HEADROOM);
  }
  





More information about the Pd-cvs mailing list