[PD-cvs] pd/src g_scalar.c,1.1.1.2.2.2.2.1,1.1.1.2.2.2.2.2 g_readwrite.c,1.1.1.3.2.1.2.2,1.1.1.3.2.1.2.3 g_graph.c,1.1.1.3.2.3.2.7,1.1.1.3.2.3.2.8 g_array.c,1.1.1.3.2.2.2.7,1.1.1.3.2.2.2.8

Mathieu Bouchard matju at users.sourceforge.net
Sat May 8 21:37:01 CEST 2004


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

Modified Files:
      Tag: impd_0_37
	g_scalar.c g_readwrite.c g_graph.c g_array.c 
Log Message:
switching to pd_error(), and using strerror() on syscalls


Index: g_array.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_array.c,v
retrieving revision 1.1.1.3.2.2.2.7
retrieving revision 1.1.1.3.2.2.2.8
diff -C2 -d -r1.1.1.3.2.2.2.7 -r1.1.1.3.2.2.2.8
*** g_array.c	3 May 2004 17:03:28 -0000	1.1.1.3.2.2.2.7
--- g_array.c	8 May 2004 19:36:59 -0000	1.1.1.3.2.2.2.8
***************
*** 9,12 ****
--- 9,13 ----
  #include "g_canvas.h"
  #include <math.h>
+ #include <errno.h>
  
  #define MIN(a,b) ((a)<(b)?(a):(b))
***************
*** 147,151 ****
      if (!template)
      {
!     	error("array: couldn't find template %s", templatesym->s_name);
      	return (0);
      }
--- 148,152 ----
      if (!template)
      {
!     	pd_error(0,"array: couldn't find template %s", templatesym->s_name);
      	return (0);
      }
***************
*** 158,162 ****
  	    || template->t_vec[i].ds_type == DT_LIST)
  	{
! 	    error("array: template %s can't have sublists or arrays",
  	    	templatesym->s_name);
      	    return (0);
--- 159,163 ----
  	    || template->t_vec[i].ds_type == DT_LIST)
  	{
! 	    pd_error(0,"array: template %s can't have sublists or arrays",
  	    	templatesym->s_name);
      	    return (0);
***************
*** 302,306 ****
  static int array_motion_npoints;
  static int array_motion_elemsize;
- /*static int array_motion_altkey;*/
  static float array_motion_initx;
  static float array_motion_xperpix;
--- 303,306 ----
***************
*** 584,588 ****
  	    &arraytype) || type != DT_FLOAT)
      	{
!     	    error("%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      	    sys_vgui(".x%x.c create text 50 50 -text foo\
--- 584,588 ----
  	    &arraytype) || type != DT_FLOAT)
      	{
!     	    pd_error(z,"%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      	    sys_vgui(".x%x.c create text 50 50 -text foo\
***************
*** 740,747 ****
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
!     	    error("%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      else if (template->t_n != 1)
!     	error("%s: has more than one field", x->x_templatesym->s_name);
      else
      {
--- 740,747 ----
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
!     	    pd_error(x,"%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      else if (template->t_n != 1)
!     	pd_error(x,"%s: has more than one field", x->x_templatesym->s_name);
      else
      {
***************
*** 762,766 ****
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	error("%s: needs floating-point '%s' field", x->x_templatesym->s_name,
      	    s->s_name);
      	return (0);
--- 762,766 ----
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	pd_error(x,"%s: needs floating-point '%s' field", x->x_templatesym->s_name,
      	    s->s_name);
      	return (0);
***************
*** 788,792 ****
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
!     	    error("%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      else for (i = 0; i < x->x_n; i++)
--- 788,792 ----
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
!     	    pd_error(x,"%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      else for (i = 0; i < x->x_n; i++)
***************
*** 812,816 ****
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
  	return;
      }
--- 812,816 ----
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	pd_error(x,"%s: needs floating-point 'y' field", x->x_templatesym->s_name);
  	return;
      }
***************
*** 835,839 ****
      if (argc < 2)
      {
!     	error("sinesum: %s: need number of points and partial strengths", x->x_templatesym->s_name);
  	return;
      }
--- 835,839 ----
      if (argc < 2)
      {
!     	pd_error(x,"sinesum: %s: need number of points and partial strengths", x->x_templatesym->s_name);
  	return;
      }
***************
*** 853,857 ****
      if (argc < 2)
      {
!     	error("sinesum: %s: need number of points and partial strengths", x->x_templatesym->s_name);
  	return;
      }
--- 853,857 ----
      if (argc < 2)
      {
!     	pd_error(x,"sinesum: %s: need number of points and partial strengths", x->x_templatesym->s_name);
  	return;
      }
***************
*** 878,882 ****
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
  	return;
      }
--- 878,882 ----
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	pd_error(x,"%s: needs floating-point 'y' field", x->x_templatesym->s_name);
  	return;
      }
***************
*** 905,909 ****
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
!     	    error("%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      else if (argc < 2) return;
--- 905,909 ----
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
!     	    pd_error(x,"%s: needs floating-point 'y' field",
  	    	x->x_templatesym->s_name);
      else if (argc < 2) return;
***************
*** 971,975 ****
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
      	return;
      }
--- 971,975 ----
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	pd_error(x,"%s: needs floating-point 'y' field", x->x_templatesym->s_name);
      	return;
      }
***************
*** 979,983 ****
  	    	|| !(fd = fdopen(filedesc, "r")))
      {
!     	error("%s: can't open", filename->s_name);
      	return;
      }
--- 979,983 ----
  	    	|| !(fd = fdopen(filedesc, "r")))
      {
!     	pd_error(x,"%s: can't open: %s", filename->s_name, strerror(errno));
      	return;
      }
***************
*** 1021,1030 ****
      else if (c)
      {
!     	error("array_read16: endianness is 'l' (low byte first ala INTEL)");
      	post("... or 'b' (high byte first ala MIPS,DEC,PPC)");
      }
      if (!garray_getfloatarray(x, &nelem, &vec))
      {
!     	error("%s: not a float array", x->x_templatesym->s_name);
      	return;
      }
--- 1021,1030 ----
      else if (c)
      {
!     	pd_error(x,"array_read16: endianness is 'l' (low byte first ala INTEL)");
      	post("... or 'b' (high byte first ala MIPS,DEC,PPC)");
      }
      if (!garray_getfloatarray(x, &nelem, &vec))
      {
!     	pd_error(x,"%s: not a float array", x->x_templatesym->s_name);
      	return;
      }
***************
*** 1034,1038 ****
  	    	|| !(fd = fdopen(filedesc, "rb")))
      {
!     	error("%s: can't open", filename->s_name);
      	return;
      }
--- 1034,1038 ----
  	    	|| !(fd = fdopen(filedesc, "rb")))
      {
!     	pd_error(x,"%s: can't open: %s", filename->s_name, strerror(errno));
      	return;
      }
***************
*** 1042,1046 ****
      	if (pos < 0)
      	{
!     	    error("%s: can't seek to byte %d", buf, skip);
      	    fclose(fd);
      	    return;
--- 1042,1046 ----
      	if (pos < 0)
      	{
!     	    pd_error(x,"%s: can't seek to byte %d: %s", buf, skip, strerror(errno));
      	    fclose(fd);
      	    return;
***************
*** 1074,1078 ****
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
      	return;
      }
--- 1074,1078 ----
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	pd_error(x,"%s: needs floating-point 'y' field", x->x_templatesym->s_name);
      	return;
      }
***************
*** 1082,1086 ****
      if (!(fd = fopen(buf, "w")))
      {
!     	error("%s: can't create", buf);
      	return;
      }
--- 1082,1086 ----
      if (!(fd = fopen(buf, "w")))
      {
!     	pd_error(x,"%s: can't create: %s", buf, strerror(errno));
      	return;
      }
***************
*** 1090,1094 ****
      	    *(float *)((x->x_vec + sizeof(t_word) * i) + yonset)) < 1)
      	{
!     	    post("%s: write error", filename->s_name);
      	    break;
      	}
--- 1090,1094 ----
      	    *(float *)((x->x_vec + sizeof(t_word) * i) + yonset)) < 1)
      	{
!     	    pd_error(x,"%s: write error: %s", filename->s_name, strerror(errno));
      	    break;
      	}
***************
*** 1111,1115 ****
  #define CLAMP(_var,_min,_max) { if (_var<_min) _var=_min; else if (_var>_max) _var=_max; }
  
- /*
  static unsigned swap32 (unsigned x) {
  	x = (x<<16) | (x>>16);
--- 1111,1114 ----
***************
*** 1117,1121 ****
  	return x;
  }
! */
  
  /* wave format only so far */
--- 1116,1124 ----
  	return x;
  }
! 
! static unsigned swap16 (unsigned short x) {
! 	x = ((x&0xff00ff)<<8) | ((x>>8)&0xff00ff);
! 	return x;
! }
  
  /* wave format only so far */
***************
*** 1146,1150 ****
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	error("%s: needs floating-point 'y' field", x->x_templatesym->s_name);
      	return;
      }
--- 1149,1153 ----
      	&type, &arraytype) || type != DT_FLOAT)
      {
!     	pd_error(x,"%s: needs floating-point 'y' field", x->x_templatesym->s_name);
      	return;
      }
***************
*** 1154,1181 ****
      if (!(fd = fopen(buf2, "wb")))
      {
!     	error("%s: can't create", buf2);
      	return;
      }
      intbuf = 2 * x->x_n + 36;
!     if (swap)
!     {
!     	unsigned char *foo = (unsigned char *)&intbuf, xxx;
!     	xxx = foo[0]; foo[0] = foo[3]; foo[3] = xxx;
!     	xxx = foo[1]; foo[1] = foo[2]; foo[2] = xxx;
!     }
      memcpy((void *)(waveheader + 4), (void *)(&intbuf), 4);
      intbuf = 2 * x->x_n;
!     if (swap)
!     {
!     	unsigned char *foo = (unsigned char *)&intbuf, xxx;
!     	xxx = foo[0]; foo[0] = foo[3]; foo[3] = xxx;
!     	xxx = foo[1]; foo[1] = foo[2]; foo[2] = xxx;
!     }
      memcpy((void *)(waveheader + 40), (void *)(&intbuf), 4);
!     if (fwrite(waveheader, sizeof(waveheader), 1, fd) < 1)
!     {
!     	post("%s: write error", buf2);
!     	goto closeit;
!     }
      for (i = 0; i < x->x_n; i++)
      {
--- 1157,1170 ----
      if (!(fd = fopen(buf2, "wb")))
      {
!     	pd_error(x,"%s: can't create: %s", buf2, strerror(errno));
      	return;
      }
      intbuf = 2 * x->x_n + 36;
!     if (swap) intbuf = swap32(intbuf);
      memcpy((void *)(waveheader + 4), (void *)(&intbuf), 4);
      intbuf = 2 * x->x_n;
!     if (swap) intbuf = swap32(intbuf);
      memcpy((void *)(waveheader + 40), (void *)(&intbuf), 4);
!     if (fwrite(waveheader, sizeof(waveheader), 1, fd) <= 0) goto error;
      for (i = 0; i < x->x_n; i++)
      {
***************
*** 1184,1198 ****
      	CLAMP(f,-32768,32767);
      	sh = f;
!     	if (swap)
!     	{
!     	    unsigned char *foo = (unsigned char *)&sh, xxx;
!     	    xxx = foo[0]; foo[0] = foo[1]; foo[1] = xxx;
!     	}
! 	if (fwrite(&sh, sizeof(sh), 1, fd) < 1)
! 	{
!     	    post("%s: write error", buf2);
!     	    goto closeit;
! 	}
      }
  closeit:
      fclose(fd);
--- 1173,1183 ----
      	CLAMP(f,-32768,32767);
      	sh = f;
!     	if (swap) sh = swap16(sh);
! 	if (fwrite(&sh, sizeof(sh), 1, fd) <= 0) goto error;
      }
+ goto closeit;
+ error:
+ 	pd_error(x,"%s: write error: %s", buf2, strerror(errno));
+ 	goto closeit;
  closeit:
      fclose(fd);

Index: g_graph.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_graph.c,v
retrieving revision 1.1.1.3.2.3.2.7
retrieving revision 1.1.1.3.2.3.2.8
diff -C2 -d -r1.1.1.3.2.3.2.7 -r1.1.1.3.2.3.2.8
*** g_graph.c	27 Apr 2004 18:09:34 -0000	1.1.1.3.2.3.2.7
--- g_graph.c	8 May 2004 19:36:59 -0000	1.1.1.3.2.3.2.8
***************
*** 401,405 ****
      	x->gl_y2 == x->gl_y1)
      {
! 	error("graph: empty bounds rectangle");
  	x1 = y1 = 0;
  	x2 = y2 = 1;
--- 401,405 ----
      	x->gl_y2 == x->gl_y1)
      {
! 	pd_error(x,"graph: empty bounds rectangle");
  	x1 = y1 = 0;
  	x2 = y2 = 1;
***************
*** 429,433 ****
  {
      int i;
!     if (argc < 1) error("graph_xlabel: no y value given");
      else
      {
--- 429,433 ----
  {
      int i;
!     if (argc < 1) pd_error(x,"graph_xlabel: no y value given");
      else
      {
***************
*** 445,449 ****
  {
      int i;
!     if (argc < 1) error("graph_ylabel: no x value given");
      else
      {
--- 445,449 ----
  {
      int i;
!     if (argc < 1) pd_error(x,"graph_ylabel: no x value given");
      else
      {

Index: g_readwrite.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_readwrite.c,v
retrieving revision 1.1.1.3.2.1.2.2
retrieving revision 1.1.1.3.2.1.2.3
diff -C2 -d -r1.1.1.3.2.1.2.2 -r1.1.1.3.2.1.2.3
*** g_readwrite.c	8 Apr 2004 01:59:51 -0000	1.1.1.3.2.1.2.2
--- g_readwrite.c	8 May 2004 19:36:59 -0000	1.1.1.3.2.1.2.3
***************
*** 39,43 ****
      int nline, char *s)
  {
!     error(s);
      startpost("line was:");
      postatom(nline, vec + message);
--- 39,43 ----
      int nline, char *s)
  {
!     pd_error(0,s);
      startpost("line was:");
      postatom(nline, vec + message);
***************
*** 55,59 ****
      if (!template)
      {
! 	error("%s: no such template", templatesym->s_name);
  	*p_nextmsg = natoms;
  	return;
--- 55,59 ----
      if (!template)
      {
! 	pd_error(x,"%s: no such template", templatesym->s_name);
  	*p_nextmsg = natoms;
  	return;
***************
*** 72,76 ****
  	    if (!arraytemplate)
  	    {
! 	    	error("%s: no such template", arraytemplatesym->s_name);
  	    }
  	    else while (1)
--- 72,76 ----
  	    if (!arraytemplate)
  	    {
! 	    	pd_error(x,"%s: no such template", arraytemplatesym->s_name);
  	    }
  	    else while (1)
***************
*** 123,127 ****
      if (!(template = template_findbyname(templatesym)))
      {
! 	error("canvas_read: %s: no such template", templatesym->s_name);
  	*p_nextmsg = natoms;
  	return (0);
--- 123,127 ----
      if (!(template = template_findbyname(templatesym)))
      {
! 	pd_error(x,"canvas_read: %s: no such template", templatesym->s_name);
  	*p_nextmsg = natoms;
  	return (0);
***************
*** 130,134 ****
      if (!sc)
      {
! 	error("couldn't create scalar \"%s\"", templatesym->s_name);
  	*p_nextmsg = natoms;
  	return (0);
--- 130,134 ----
      if (!sc)
      {
! 	pd_error(x,"couldn't create scalar \"%s\"", templatesym->s_name);
  	*p_nextmsg = natoms;
  	return (0);
***************
*** 213,217 ****
      	if (!(existtemplate = template_findbyname(templatesym)))
  	{
! 	    error("%s: template not found in current patch",
  	    	templatesym->s_name);
  	    template_free(newtemplate);
--- 213,217 ----
      	if (!(existtemplate = template_findbyname(templatesym)))
  	{
! 	    pd_error(x,"%s: template not found in current patch",
  	    	templatesym->s_name);
  	    template_free(newtemplate);
***************
*** 220,224 ****
  	if (!template_match(existtemplate, newtemplate))
  	{
! 	    error("%s: template doesn't match current one",
  	    	templatesym->s_name);
  	    template_free(newtemplate);
--- 220,224 ----
  	if (!template_match(existtemplate, newtemplate))
  	{
! 	    pd_error(x,"%s: template doesn't match current one",
  	    	templatesym->s_name);
  	    template_free(newtemplate);
***************
*** 244,248 ****
      	cr = 1;
      else if (*format->s_name)
!     	error("qlist_read: unknown flag: %s", format->s_name);
      
      if (binbuf_read_via_path(b, filename->s_name,
--- 244,248 ----
      	cr = 1;
      else if (*format->s_name)
!     	pd_error(x,"qlist_read: unknown flag: %s", format->s_name);
      
      if (binbuf_read_via_path(b, filename->s_name,
***************
*** 308,312 ****
      }
      if (!newone)
!     	error("couldn't update properties (perhaps a format problem?)");
      else if (!oldone)
      	bug("data_properties: couldn't find old element");
--- 308,312 ----
      }
      if (!newone)
!     	pd_error(x,"couldn't update properties (perhaps a format problem?)");
      else if (!oldone)
      	bug("data_properties: couldn't find old element");
***************
*** 534,538 ****
      	cr = 1;
      else if (*format->s_name)
!     	error("qlist_read: unknown flag: %s", format->s_name);
      
      b = glist_writetobinbuf(x, 1);
--- 534,538 ----
      	cr = 1;
      else if (*format->s_name)
!     	pd_error(x,"qlist_read: unknown flag: %s", format->s_name);
      
      b = glist_writetobinbuf(x, 1);
***************
*** 540,544 ****
      {
      	if (binbuf_write(b, buf, "", cr))
!     	    error("%s: write failed", filename->s_name);
      	binbuf_free(b);
      }
--- 540,544 ----
      {
      	if (binbuf_write(b, buf, "", cr))
!     	    pd_error(x,"%s: write failed", filename->s_name);
      	binbuf_free(b);
      }

Index: g_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_scalar.c,v
retrieving revision 1.1.1.2.2.2.2.1
retrieving revision 1.1.1.2.2.2.2.2
diff -C2 -d -r1.1.1.2.2.2.2.1 -r1.1.1.2.2.2.2.2
*** g_scalar.c	1 Apr 2004 23:22:02 -0000	1.1.1.2.2.2.2.1
--- g_scalar.c	8 May 2004 19:36:59 -0000	1.1.1.2.2.2.2.2
***************
*** 114,118 ****
      if (!template)
      {
!     	error("scalar: couldn't find template %s", templatesym->s_name);
      	return (0);
      }
--- 114,118 ----
      if (!template)
      {
!     	pd_error(0,"scalar: couldn't find template %s", templatesym->s_name);
      	return (0);
      }
***************
*** 238,242 ****
      if (!template)
      {
!     	error("scalar: couldn't find template %s", templatesym->s_name);
  	return;
      }
--- 238,242 ----
      if (!template)
      {
!     	pd_error(z,"scalar: couldn't find template %s", templatesym->s_name);
  	return;
      }
***************
*** 375,379 ****
      if (!template)
      {
!     	error("scalar: couldn't find template %s", templatesym->s_name);
  	return;
      }
--- 375,379 ----
      if (!template)
      {
!     	pd_error(x,"scalar: couldn't find template %s", templatesym->s_name);
  	return;
      }





More information about the Pd-cvs mailing list