aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-07-01 19:37:24 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-07-01 19:37:24 +0000
commit8096cea9ef6d6d8260e05c7aa31f91ab2a85d506 (patch)
tree029d7c3e04e626ec112f9126bac443f001aa2202
parentd8d052b3fc690bc4f1c018419c719106f69dbd5b (diff)
+ 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
-rw-r--r--src/iemlib2/splitfilename.c26
1 files changed, 19 insertions, 7 deletions
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));
}