if ((p = strrchr(*argv, '/')) == NULL) p = *argv; else ++p;
char *current_arg = *argv;   if ((p = strrchr(current_arg, '/')) == NULL) p = current_arg; else {  if (!*(p+1)) { while ((p >= current_arg) && *p == '/') p--;  while ((p >= current_arg) && *p != '/') p--; }  p++; }
main(argc, argv)	int argc;	char *argv[];{	register int baselen, len, rval;	register char *p, *endp;	struct stat sb;	int ch;	char path[MAXPATHLEN];	while ((ch = getopt(argc, argv, "if")) != -1)		switch (ch) {		case 'i':			fflg = 0;			iflg = 1;			break;		case 'f':			iflg = 0;			fflg = 1;			break;		default:			usage();		}	argc -= optind;	argv += optind;	if (argc < 2)		usage();	stdin_ok = isatty(STDIN_FILENO);	/*	 * If the stat on the target fails or the target isn't a directory,	 * try the move.  More than 2 arguments is an error in this case.	 */	if (stat(argv[argc - 1], &sb) || !S_ISDIR(sb.st_mode)) {		if (argc > 2)			usage();		exit(do_move(argv[0], argv[1]));	}	/* It's a directory, move each file into it. */	if (strlen(argv[argc - 1]) > sizeof path - 1)		errx(1, "%s: destination pathname too long", *argv);	(void)strcpy(path, argv[argc - 1]);	baselen = strlen(path);	endp = &path[baselen];	if (*(endp - 1) != '/') {		*endp++ = '/';		++baselen;	}	for (rval = 0; --argc; ++argv) {		if ((p = strrchr(*argv, '/')) == NULL)			p = *argv;		else			++p;		if ((baselen + (len = strlen(p))) >= MAXPATHLEN) {			warnx("%s: destination pathname too long", *argv);			rval = 1;		} else {			memmove(endp, p, len + 1);			if (do_move(*argv, path))				rval = 1;		}	}	exit(rval);}