[PD-cvs] externals/iemlib/src/iemlib2 splitfilename.c,1.2,1.3

IOhannes m zmölnig zmoelnig at users.sourceforge.net
Fri Jul 1 21:37:26 CEST 2005


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

Modified Files:
	splitfilename.c 
Log Message:
+ check whether the result of strrchr() is NULL
+ do not typecast (char*) to (int); pointer arithmetic is weird but works whereas the cast from pointer to int will not work on non-32bit architecture (e.g. x86-64)


Index: splitfilename.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iemlib/src/iemlib2/splitfilename.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** splitfilename.c	2 Jun 2005 18:25:00 -0000	1.2
--- splitfilename.c	1 Jul 2005 19:37:24 -0000	1.3
***************
*** 90,110 ****
  			cpp = strrchr(str_path, x->x_sep[0]);
  			cpf = strrchr(str_file, x->x_sep[0]);
! 			if(((int)cpp - (int)str_path) < 0)
  			{
  				outlet_symbol(x->x_outfile, gensym(str_file));
! 				outlet_symbol(x->x_outpath, &s_);
! 			}
! 			else if(((int)cpp - (int)str_path) >= len)
  			{
  				outlet_symbol(x->x_outfile, &s_);
  				outlet_symbol(x->x_outpath, gensym(str_path));
  			}
! 			else
! 			{
  				*cpp = 0;
  				cpf++;
  				outlet_symbol(x->x_outfile, gensym(cpf));
  				outlet_symbol(x->x_outpath, gensym(str_path));
! 			}
  			freebytes(str_file, len*sizeof(char));
  			freebytes(str_path, len*sizeof(char));
--- 90,122 ----
  			cpp = strrchr(str_path, x->x_sep[0]);
  			cpf = strrchr(str_file, x->x_sep[0]);
! 			if(!cpp) /* JMZ: 20050701 */
  			{
+ 			  post("1");
  				outlet_symbol(x->x_outfile, gensym(str_file));
! 				outlet_symbol(x->x_outpath, &s_);			  
! 			} 
! 			else if (!cpf) /* JMZ: 20050701 */
  			{
+ 			  post("2");
  				outlet_symbol(x->x_outfile, &s_);
  				outlet_symbol(x->x_outpath, gensym(str_path));
  			}
! 			else if((cpp - str_path) < 0) /* JMZ:removed typecast (char*) to (int); this is not portable */
! 			  {
! 				outlet_symbol(x->x_outfile, gensym(str_file));
! 				outlet_symbol(x->x_outpath, &s_);
! 			  }
! 			else if((cpp - str_path) >= len) /* JMZ: removed typecast (char*) to (int) */
! 			    {
! 				outlet_symbol(x->x_outfile, &s_);
! 				outlet_symbol(x->x_outpath, gensym(str_path));
! 			  }
! 			  else
! 			  {
  				*cpp = 0;
  				cpf++;
  				outlet_symbol(x->x_outfile, gensym(cpf));
  				outlet_symbol(x->x_outpath, gensym(str_path));
! 			  }
  			freebytes(str_file, len*sizeof(char));
  			freebytes(str_path, len*sizeof(char));





More information about the Pd-cvs mailing list