[PD-cvs] pd/src desire.c,1.1.2.63,1.1.2.64

Mathieu Bouchard matju at users.sourceforge.net
Sat Dec 3 07:56:29 CET 2005


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

Modified Files:
      Tag: devel_0_39
	desire.c 
Log Message:
fixed tcl quoting bug in post()


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.63
retrieving revision 1.1.2.64
diff -C2 -d -r1.1.2.63 -r1.1.2.64
*** desire.c	3 Dec 2005 06:40:36 -0000	1.1.2.63
--- desire.c	3 Dec 2005 06:56:26 -0000	1.1.2.64
***************
*** 12948,12959 ****
  /* formerly s_print.c */
  
- /*
- #include "m_pd.h"
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <string.h>
- #include "s_stuff.h"
- */
  #include <errno.h>
  
--- 12948,12951 ----
***************
*** 12961,12998 ****
  int sys_printtostderr;
  
! static void dopost(const char *s)
! {
!     if (sys_printhook)
!         (*sys_printhook)(s);
!     else if (sys_printtostderr)
!         fprintf(stderr, "%s", s);
!     else
!     {
!         char upbuf[MAXPDSTRING];
!         int ptin = 0, ptout = 0, len = strlen(s);
!         static int heldcr = 0;
!         if (heldcr)
!             upbuf[ptout++] = '\n', heldcr = 0;
!         for (; ptin < len && ptout < MAXPDSTRING-3;
!             ptin++, ptout++)
!         {
!             int c = s[ptin];
!             if (c == '\\' || c == '{' || c == '}' || c == ';')
!                 upbuf[ptout++] = '\\';
!             upbuf[ptout] = s[ptin];
          }
!         if (ptout && upbuf[ptout-1] == '\n')
!             upbuf[--ptout] = 0, heldcr = 1;
!         upbuf[ptout] = 0;
!         sys_vgui("pdtk_post {%s}\n", upbuf);
      }
  }
  
! void post(const char *fmt, ...)
! {
      char buf[MAXPDSTRING];
      va_list ap;
-     t_int arg[8];
-     int i;
      va_start(ap, fmt);
      vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
--- 12953,12974 ----
  int sys_printtostderr;
  
! static void dopost(const char *s) {
!     if (sys_printhook) sys_printhook(s);
!     else if (sys_printtostderr) fprintf(stderr, "%s", s);
!     else {
!         char t[MAXPDSTRING];
!         int i,j=0;
!         for(i=0; s[i] && j<MAXPDSTRING-16; i++) {
!             if (index("\\\"[]$\n",s[i])) t[j++]='\\';
! 	    if (s[i]=='\n') t[j++]='n'; else t[j++] = s[i];
          }
!         t[j] = 0;
!         sys_vgui("pdtk_post \"%s\"\n",t);
      }
  }
  
! void post(const char *fmt, ...) {
      char buf[MAXPDSTRING];
      va_list ap;
      va_start(ap, fmt);
      vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
***************
*** 13002,13011 ****
  }
  
! void startpost(const char *fmt, ...)
! {
      char buf[MAXPDSTRING];
      va_list ap;
-     t_int arg[8];
-     int i;
      va_start(ap, fmt);
      vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
--- 12978,12984 ----
  }
  
! void startpost(const char *fmt, ...) {
      char buf[MAXPDSTRING];
      va_list ap;
      va_start(ap, fmt);
      vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
***************
*** 13014,13053 ****
  }
  
! void poststring(const char *s)
! {
!     dopost(" ");
!     dopost(s);
! }
  
! void postatom(int argc, t_atom *argv)
! {
      int i;
!     for (i = 0; i < argc; i++)
!     {
!         char buf[80];
!         atom_string(argv+i, buf, 80);
          poststring(buf);
      }
  }
  
! void postfloat(float f)
! {
!     char buf[80];
!     t_atom a;
!     SETFLOAT(&a, f);
!     postatom(1, &a);
! }
! 
! void endpost(void)
! {
!     dopost("\n");
! }
  
! void error(const char *fmt, ...)
! {
      char buf[MAXPDSTRING];
      va_list ap;
-     t_int arg[8];
-     int i;
      dopost("error: ");
      va_start(ap, fmt);
--- 12987,13007 ----
  }
  
! void poststring(const char *s) {dopost(" "); dopost(s);}
  
! void postatom(int argc, t_atom *argv) {
!     char buf[MAXPDSTRING];
      int i;
!     for (i=0; i<argc; i++) {
!         atom_string(argv+i,buf,MAXPDSTRING);
          poststring(buf);
      }
  }
  
! void postfloat(float f) {t_atom a; SETFLOAT(&a, f); postatom(1, &a);}
! void endpost(void) {dopost("\n");}
  
! void error(const char *fmt, ...) {
      char buf[MAXPDSTRING];
      va_list ap;
      dopost("error: ");
      va_start(ap, fmt);
***************
*** 13058,13072 ****
  }
  
! void verbose(int level, const char *fmt, ...)
! {
      char buf[MAXPDSTRING];
      va_list ap;
!     t_int arg[8];
!     int i;
!     if(level>sys_verbose)return;
      dopost("verbose(");
      postfloat((float)level);
      dopost("):");
-     
      va_start(ap, fmt);
      vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
--- 13012,13022 ----
  }
  
! void verbose(int level, const char *fmt, ...) {
      char buf[MAXPDSTRING];
      va_list ap;
!     if (level>sys_verbose) return;
      dopost("verbose(");
      postfloat((float)level);
      dopost("):");
      va_start(ap, fmt);
      vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
***************
*** 13076,13082 ****
  }
  
!     /* here's the good way to log errors -- keep a pointer to the
!     offending or offended object around so the user can search for it
!     later. */
  
  static void *error_object;
--- 13026,13032 ----
  }
  
! /* here's the good way to log errors -- keep a pointer to the
! offending or offended object around so the user can search for it
! later. */
  
  static void *error_object;
***************
*** 13084,13093 ****
  void canvas_finderror(void *object);
  
! void pd_error(void *object, const char *fmt, ...)
! {
      char buf[MAXPDSTRING];
      va_list ap;
-     t_int arg[8];
-     int i;
      static int saidit;
      dopost("error: ");
--- 13034,13040 ----
  void canvas_finderror(void *object);
  
! void pd_error(void *object, const char *fmt, ...) {
      char buf[MAXPDSTRING];
      va_list ap;
      static int saidit;
      dopost("error: ");
***************
*** 13105,13114 ****
  }
  
! void glob_finderror(t_pd *dummy)
! {
!     if (!error_object)
!         post("no findable error yet.");
!     else
!     {
          post("last trackable error:");
          post("%s", error_string);
--- 13052,13060 ----
  }
  
! /* this proc is a big bug (hint: error string is uninitialized _and_ never initialized).
! who did this? what is it supposed to be? */
! void glob_finderror(t_pd *dummy) {
!     if (!error_object) post("no findable error yet.");
!     else {
          post("last trackable error:");
          post("%s", error_string);
***************
*** 13117,13126 ****
  }
  
! void bug(const char *fmt, ...)
! {
      char buf[MAXPDSTRING];
      va_list ap;
-     t_int arg[8];
-     int i;
      dopost("consistency check failed: ");
      va_start(ap, fmt);
--- 13063,13069 ----
  }
  
! void bug(const char *fmt, ...) {
      char buf[MAXPDSTRING];
      va_list ap;
      dopost("consistency check failed: ");
      va_start(ap, fmt);
***************
*** 13135,13152 ****
  static const char *errstring;
  
! void sys_logerror(const char *object, const char *s)
! {
!     errobject = object;
!     errstring = s;
! }
! 
! void sys_unixerror(const char *object)
! {
!     errobject = object;
!     errstring = strerror(errno);
! }
  
! void sys_ouch(void)
! {
      if (*errobject) error("%s: %s", errobject, errstring);
      else error("%s", errstring);
--- 13078,13085 ----
  static const char *errstring;
  
! void sys_logerror (const char *object, const char *s){errobject=object; errstring = s;}
! void sys_unixerror(const char *object)               {errobject=object; errstring = strerror(errno);}
  
! void sys_ouch(void) {
      if (*errobject) error("%s: %s", errobject, errstring);
      else error("%s", errstring);





More information about the Pd-cvs mailing list