utility
|
cmd_head.c,
count_tokens.c,
cp_file.c,
errmsg.c,
file_opened.c,
find_line.c,
find_string.c,
fn_base.c,
fn_dir.c,
fn_ext.c,
fn_root.c,
gchoice.c,
gdata_line.c,
gdouble.c,
gfield.c,
gint.c,
gntoken.c,
graphics_ok.c,
gstring.c,
lock.c,
lower.c,
mat_multiply.c,
mat_transform.c,
mat_transpose.c,
mv_file.c,
new_extension.c,
nolead.c,
notrail.c,
ordinal.c,
pfield.c,
squish_blanks.c,
test.c,
unlock.c,
upper.c,
utility.h,
utility.make,
valchars.c,
vec_angle.c,
vec_crossprod.c,
vec_diff.c,
vec_dotprod.c,
vec_length.c,
vec_norm.c,
|
|
|
#include "utility.h"
char *new_extension(filename,extension)
/*============================================================================*/
/* PURPOSE: REMOVE THE CURRENT EXTENSION (IF ANY) ON FILENAME, AND APPEND THE
/* SPECIFIED EXTENSION. AN "EXTENSION" IS DEFINED TO BE THE LAST PERIOD
/* IN THE FILENAME AND ALL CHARACTERS FOLLOWING IT. A LEADING PERIOD IS
/* OPTIONAL IN THE NEW EXTENSION - IF NOT PRESENT, IT WILL BE ADDED.
/* INPUTS:
/* FILENAME ORIGINAL FILENAME WITH OPTIONAL EXTENSION.
/* EXTENSION NEW EXTENSION TO APPEND TO FILENAME AFTER PREVIOUS
/* EXTENSION IS REMOVED.
/* OUTPUTS:
/* FILENAME THE ORIGINAL FILENAME WITH THE NEW EXTENSION.
/* RETURN VALUE POINTER TO MODIFIED FILENAME.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
char filename[];
char extension[];
{
char *last_period; /* POINTER TO LAST PERIOD IN FILENAME. */
last_period=strrchr(filename,'.'); /* FIND THE LAST PERIOD. */
if (last_period!=NULL) *last_period=0; /* TRIM OFF OLD EXTENSION. */
if (extension[0]!='.') strcat(filename,"."); /* GUARANTEE A PERIOD. */
strcat(filename,extension); /* APPEND NEW EXTENSION. */
return(filename);
}
|