From 2d5b64273fb10938f963ea845bf558b55c3884fa Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 22 Dec 2000 18:02:02 +0000 Subject: [PATCH] Cleanup from Gennady Feldman --- lash.c | 10 ++-------- sh.c | 10 ++-------- shell/lash.c | 10 ++-------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/lash.c b/lash.c index a47ff5ca2..14571169b 100644 --- a/lash.c +++ b/lash.c @@ -807,14 +807,8 @@ static int get_command(FILE * source, char *command) signal(SIGWINCH, SIG_DFL); return 0; #else - i=strlen(cwd); - i--; - if (i>1){ - while ((i>0) && (*(cwd+i)!='/') ) i--; - if (*(cwd+i)=='/') i++; - } - - fprintf(stdout, "[%s@%s %s]%s",user, buf, (cwd+i), prompt); + fprintf(stdout, "[%s@%s %s]%s",user, buf, + get_last_path_component(cwd), prompt); fflush(stdout); #endif } diff --git a/sh.c b/sh.c index a47ff5ca2..14571169b 100644 --- a/sh.c +++ b/sh.c @@ -807,14 +807,8 @@ static int get_command(FILE * source, char *command) signal(SIGWINCH, SIG_DFL); return 0; #else - i=strlen(cwd); - i--; - if (i>1){ - while ((i>0) && (*(cwd+i)!='/') ) i--; - if (*(cwd+i)=='/') i++; - } - - fprintf(stdout, "[%s@%s %s]%s",user, buf, (cwd+i), prompt); + fprintf(stdout, "[%s@%s %s]%s",user, buf, + get_last_path_component(cwd), prompt); fflush(stdout); #endif } diff --git a/shell/lash.c b/shell/lash.c index a47ff5ca2..14571169b 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -807,14 +807,8 @@ static int get_command(FILE * source, char *command) signal(SIGWINCH, SIG_DFL); return 0; #else - i=strlen(cwd); - i--; - if (i>1){ - while ((i>0) && (*(cwd+i)!='/') ) i--; - if (*(cwd+i)=='/') i++; - } - - fprintf(stdout, "[%s@%s %s]%s",user, buf, (cwd+i), prompt); + fprintf(stdout, "[%s@%s %s]%s",user, buf, + get_last_path_component(cwd), prompt); fflush(stdout); #endif } -- 2.25.1