
/**************************************************************************
 *                                                                        *
 * Copyright (c) 1996 Michael Richmond and Richard Treffers               *
 *                                                                        *
 *                    This software may be copied and distributed for     *
 *                    educational, research and not for profit services   *
 *                    provided that this copyright and statement are      *
 *                    included in all such copies.                        *
 *                                                                        *
 **************************************************************************/



/* routine to modify file name extensions 		*/
/*  	fname - is the filename string input 	*/
/*	    ext - is file extension			   		*/
/* example: if fname="blah.obj"  and ext=".exe" */
/* 			fname becomes "blah.exe"			*/

/*	Fix from Steve Walton inserted 1/30/91 by MWR.  Fixes relative paths
	correctly now. */

#include <stdio.h>
#include <string.h>
#include "pcvista.h"

void exten(fname, ext)
char *fname, *ext;
{
	char *p;

	/* set pointer p to one char past the last occurence of slash, or at the
	   start of the file name if no slash */
	if (((p = strrchr(fname, '/')) == NULL) && 
	    ((p = strrchr(fname, '\\')) == NULL))
		p = fname;
	else
		p++;				/* point to one char past closing brace */

	/* find the period in the file name, if any */
	if ((p = strchr(p, '.')) == NULL)
		 p = fname + strlen(fname);
	strcpy(p, ext);
}
