[PD-cvs] pd/src m_binbuf.c,1.4.4.1.2.8.2.2,1.4.4.1.2.8.2.3

Mathieu Bouchard matju at users.sourceforge.net
Fri Dec 8 07:15:50 CET 2006


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

Modified Files:
      Tag: desiredata
	m_binbuf.c 
Log Message:
0.40


Index: m_binbuf.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_binbuf.c,v
retrieving revision 1.4.4.1.2.8.2.2
retrieving revision 1.4.4.1.2.8.2.3
diff -C2 -d -r1.4.4.1.2.8.2.2 -r1.4.4.1.2.8.2.3
*** m_binbuf.c	30 Nov 2006 18:10:51 -0000	1.4.4.1.2.8.2.2
--- m_binbuf.c	8 Dec 2006 06:15:47 -0000	1.4.4.1.2.8.2.3
***************
*** 96,101 ****
                  /* it's an atom other than a comma or semi */
              char c;
!             int floatstate = 0, slash = 0, lastslash = 0,
!                 firstslash = (*textp == '\\');
              bufp = buf;
              do
--- 96,100 ----
                  /* it's an atom other than a comma or semi */
              char c;
!             int floatstate = 0, slash = 0, lastslash = 0, dollar = 0;
              bufp = buf;
              do
***************
*** 162,165 ****
--- 161,167 ----
                      }
                  }
+                 if (!lastslash && c == '$' && (textp != etext && 
+                     textp[0] >= '0' && textp[0] <= '9'))
+                         dollar = 1;
                  if (!slash) bufp++;
              }
***************
*** 173,196 ****
              *bufp = 0;
  #if 0
!             post("buf %s", buf);
  #endif
!             if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9' && !firstslash)
              {
!                 for (bufp = buf+2; *bufp; bufp++)
                      if (*bufp < '0' || *bufp > '9')
!                 {
!                     SETDOLLSYM(ap, gensym(buf+1));
!                     goto didit;
!                 }
!                 SETDOLLAR(ap, atoi(buf+1));
!             didit: ;
!             }
!             else
!             {
!                 if (floatstate == 2 || floatstate == 4 || floatstate == 5 ||
!                     floatstate == 8)
!                         SETFLOAT(ap, atof(buf));
!                 else SETSYMBOL(ap, gensym(buf));
              }
          }
          ap++;
--- 175,199 ----
              *bufp = 0;
  #if 0
!             post("binbuf_text: buf %s", buf);
  #endif
!             if (floatstate == 2 || floatstate == 4 || floatstate == 5 ||
!                 floatstate == 8)
!                     SETFLOAT(ap, atof(buf));
!                 /* LATER try to figure out how to mix "$" and "\$" correctly;
!                 here, the backslashes were already stripped so we assume all
!                 "$" chars are real dollars.  In fact, we only know at least one
!                 was. */
!             else if (dollar)
              {
!                 if (buf[0] != '$') 
!                     dollar = 0;
!                 for (bufp = buf+1; *bufp; bufp++)
                      if (*bufp < '0' || *bufp > '9')
!                         dollar = 0;
!                 if (dollar)
!                     SETDOLLAR(ap, atoi(buf+1));
!                 else SETDOLLSYM(ap, gensym(buf));
              }
+             else SETSYMBOL(ap, gensym(buf));
          }
          ap++;
***************
*** 331,335 ****
              break;
          case A_DOLLSYM:
!             sprintf(tbuf, "$%s", ap->a_w.w_symbol->s_name);
              SETSYMBOL(ap, gensym(tbuf));
              break;
--- 334,338 ----
              break;
          case A_DOLLSYM:
!             atom_string(ap, tbuf, MAXPDSTRING);
              SETSYMBOL(ap, gensym(tbuf));
              break;
***************
*** 376,391 ****
          if (argv->a_type == A_SYMBOL)
          {
!             char *str = argv->a_w.w_symbol->s_name;
              if (!strcmp(str, ";")) SETSEMI(ap);
              else if (!strcmp(str, ",")) SETCOMMA(ap);
!             else if (str[0] == '$' && str[1] >= '0' && str[1] <= '9')
              {
                  int dollsym = 0;
!                 char *str2;
!                 for (str2 = str + 2; *str2; str2++)
                      if (*str2 < '0' || *str2 > '9')
!                         dollsym = 1;
                  if (dollsym)
!                     SETDOLLSYM(ap, gensym(str + 1));
                  else
                  {
--- 379,399 ----
          if (argv->a_type == A_SYMBOL)
          {
!             char *str = argv->a_w.w_symbol->s_name, *str2;
              if (!strcmp(str, ";")) SETSEMI(ap);
              else if (!strcmp(str, ",")) SETCOMMA(ap);
!             else if ((str2 = strchr(str, '$')) && str2[1] >= '0'
!                 && str2[1] <= '9')
              {
                  int dollsym = 0;
!                 if (*str != '$')
!                     dollsym = 1;
!                 else for (str2 = str + 1; *str2; str2++)
                      if (*str2 < '0' || *str2 > '9')
!                 {
!                     dollsym = 1;
!                     break;
!                 }
                  if (dollsym)
!                     SETDOLLSYM(ap, gensym(str));
                  else
                  {
***************
*** 663,668 ****
                      target == &pd_objectmaker);
                  if (!s9)
!                     goto broken;
!                 SETSYMBOL(msp, s9);
                  break;
              default:
--- 671,679 ----
                      target == &pd_objectmaker);
                  if (!s9)
!                 {
!                     error("%s: argument number out of range", at->a_w.w_symbol->s_name);
!                     SETSYMBOL(msp, at->a_w.w_symbol);
!                 }
!                 else SETSYMBOL(msp, s9);
                  break;
              default:
***************
*** 772,775 ****
--- 783,805 ----
  }
  
+     /* 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);
+     if (binbuf_read(b, bufptr, buf, crflag))
+         return (1);
+     else return (0);
+ }
+ 
+     /* old version */
  int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
      int crflag)
***************
*** 927,931 ****
                  {
                      char buf[100];
!                     sprintf(buf, "$%s", nextmess[i].a_w.w_symbol->s_name);
                      SETSYMBOL(nextmess+i, gensym(buf));
                  }
--- 957,961 ----
                  {
                      char buf[100];
!                     sprintf(buf, "%s", nextmess[i].a_w.w_symbol->s_name);
                      SETSYMBOL(nextmess+i, gensym(buf));
                  }





More information about the Pd-cvs mailing list