version 1.15, 2002/07/05 05:39:42 |
version 1.16, 2003/04/14 04:51:28 |
|
|
char *file; |
char *file; |
char *res; |
char *res; |
char *p; |
char *p; |
|
size_t len; |
|
|
if ((file = strrchr(path, '/')) == NULL) |
if ((file = strrchr(path, '/')) == NULL) |
file = path; |
file = path; |
else |
else |
file++; |
file++; |
|
|
res = alloc(strlen(file) + strlen(ext) + 1); |
len = strlen(file) + strlen(ext) + 1; |
|
res = alloc(len); |
if (res == NULL) { |
if (res == NULL) { |
fprintf(stderr, "could not allocate memory\n"); |
fprintf(stderr, "could not allocate memory\n"); |
exit(1); |
exit(1); |
|
|
p = strrchr(file, '.'); |
p = strrchr(file, '.'); |
if (p == NULL) |
if (p == NULL) |
p = file + strlen(file); |
p = file + strlen(file); |
(void) strcpy(res, file); |
(void) strlcpy(res, file, len); |
(void) strcpy(res + (p - file), ext); |
(void) strlcpy(res, ext, len - (p - file)); |
return (res); |
return (res); |
} |
} |
|
|