6 main(int argc, char **argv)
11 if(argc < 2 || argc > 3){
12 fprintf(stderr, "Usage: basename string [suffix]\n");
16 b = s + strlen(s) - 1;
17 while(b > s && *b == '/')
20 if(b == s+1 && s[0] == '/') {
24 /* now b is after last char of string, trailing slashes removed */
26 for(f = b; f >= s; f--)
34 /* now f is first char after last remaining slash, or first char */
38 if(n < b-f && strncmp(b-n, argv[2], n) == 0){