gno/usr.orca.bin/describe/basename.c
gdr 3a79f5a3a6 Describe (and related utils), version 1.0.1. Like v1.0, this checkin
does not include resource forks.  See the README for changes.

This update by Devin Reade.
1996-01-22 01:38:06 +00:00

31 lines
512 B
C

#pragma optimize -1
#include <string.h>
#include <stdio.h>
#include <unistd.h>
char *basename (char *name) {
char *p, brk;
/* checking for ':' is GS-specific */
brk = (strchr(name,':')) ? ':' : '/';
p = strrchr(name,brk);
return ((p) ? p+1 : name);
}
#ifdef SHELLCOMD
int main (int argc, char **argv) {
if (argc != 2) {
fprintf(stderr,"Usage: basename file_name\nVersion 1.0\n");
return -1;
}
printf("%s\n",basename(argv[1]));
return 0;
}
#endif /* SHELLCOMD */