X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=c1e8eee4f9c492a11ba7829282c967a89b09e4b8;hb=0e661055e1233e585fb259832e4884f68d3833a4;hp=c568159d41d4adf5c43781c4d2afa40f9f62ba19;hpb=d99870c374ff3c25290e15c38a402cbfa3d240e6;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index c568159d..c1e8eee4 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -654,6 +654,23 @@ char *getBaseName(char *filename) return getStringCopy(getBaseNamePtr(filename)); } +char *getBaseNameNoSuffix(char *filename) +{ + char *basename = getStringCopy(getBaseNamePtr(filename)); + + // remove trailing suffix (separated by dot or hyphen) + if (basename[0] != '.' && basename[0] != '-') + { + if (strchr(basename, '.') != NULL) + *strchr(basename, '.') = '\0'; + + if (strchr(basename, '-') != NULL) + *strchr(basename, '-') = '\0'; + } + + return basename; +} + char *getBasePath(char *filename) { char *basepath = getStringCopy(filename); @@ -1306,7 +1323,7 @@ void clear_mem(void *ptr, unsigned int size) /* various helper functions */ /* ------------------------------------------------------------------------- */ -inline void swap_numbers(int *i1, int *i2) +void swap_numbers(int *i1, int *i2) { int help = *i1; @@ -1314,7 +1331,7 @@ inline void swap_numbers(int *i1, int *i2) *i2 = help; } -inline void swap_number_pairs(int *x1, int *y1, int *x2, int *y2) +void swap_number_pairs(int *x1, int *y1, int *x2, int *y2) { int help_x = *x1; int help_y = *y1;