FreeBSD/usr.bin/last/last.c
/*
 * ttyconv --
 *	convert tty to correct name.
 */
ttyconv
convert tty to correct name.
ttyconv convert tty to correct name .
static char *
ttyconv(char *arg)
{
	char *mval;
	if (strlen(arg) == 2) {
		if ((mval = malloc(8)) == NULL)
			errx(1, "malloc failure");
		if (!strcmp(arg, "co"))
			(void)strcpy(mval, "console");
		else {
			(void)strcpy(mval, "tty");
			(void)strcpy(mval + 3, arg);
		}
		return (mval);
	}
	if (!strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1))
		return (arg + 5);
	return (arg);
}
static char * ttyconv ( char * arg ) { char * mval ; if ( strlen ( arg ) == 2 ) { if ( ( mval = malloc ( 8 ) ) == NULL ) errx ( 1 , " " ) ; if ( ! strcmp ( arg , " " ) ) ( void ) strcpy ( mval , " " ) ; else { ( void ) strcpy ( mval , " " ) ; ( void ) strcpy ( mval + 3 , arg ) ; } return ( mval ) ; } if ( ! strncmp ( arg , _PATH_DEV , sizeof ( _PATH_DEV ) - 1 ) ) return ( arg + 5 ) ; return ( arg ) ; }
ttyconv
      convert tty to correct name.
ttyconv convert tty to correct name .
/*
	 * kludge -- we assume that all tty's end with
	 * a two character suffix.
	 */ /* either 6 for "ttyxx" or 8 for "console" */