From 8096cea9ef6d6d8260e05c7aa31f91ab2a85d506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Fri, 1 Jul 2005 19:37:24 +0000 Subject: + 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) svn path=/trunk/externals/iemlib/; revision=3280 --- src/iemlib2/splitfilename.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/iemlib2') diff --git a/src/iemlib2/splitfilename.c b/src/iemlib2/splitfilename.c index 2d23f0b..f0720a7 100644 --- a/src/iemlib2/splitfilename.c +++ b/src/iemlib2/splitfilename.c @@ -89,23 +89,35 @@ static void splitfilename_symbol(t_splitfilename *x, t_symbol *s) strcpy(str_file, s->s_name); cpp = strrchr(str_path, x->x_sep[0]); cpf = strrchr(str_file, x->x_sep[0]); - if(((int)cpp - (int)str_path) < 0) + if(!cpp) /* JMZ: 20050701 */ { + post("1"); 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_outpath, &s_); + } + else if (!cpf) /* JMZ: 20050701 */ { + post("2"); outlet_symbol(x->x_outfile, &s_); outlet_symbol(x->x_outpath, gensym(str_path)); } - else - { + 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)); } -- cgit v1.2.1