aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-04-23 15:05:26 +0100
committerRon Yorston <rmy@pobox.com>2012-04-23 15:05:26 +0100
commit15e948bdabe8fc69d821a20dfe2bf00b56eb99f3 (patch)
tree34375189e2091646ed6f4d55ab0aad172dc471f2 /libbb
parent7543523a11fbc3b8835a334651a3a8084c8a65b7 (diff)
downloadbusybox-w32-15e948bdabe8fc69d821a20dfe2bf00b56eb99f3.tar.gz
busybox-w32-15e948bdabe8fc69d821a20dfe2bf00b56eb99f3.tar.bz2
busybox-w32-15e948bdabe8fc69d821a20dfe2bf00b56eb99f3.zip
win32: support fancy prompts and (limited) tilde expansion
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 77dc1c607..b3ae21510 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -647,6 +647,7 @@ static char *username_path_completion(char *ud)
647 if (*ud == '/') { /* "~/..." */ 647 if (*ud == '/') { /* "~/..." */
648 home = home_pwd_buf; 648 home = home_pwd_buf;
649 } else { 649 } else {
650#if !ENABLE_PLATFORM_MINGW32
650 /* "~user/..." */ 651 /* "~user/..." */
651 ud = strchr(ud, '/'); 652 ud = strchr(ud, '/');
652 *ud = '\0'; /* "~user" */ 653 *ud = '\0'; /* "~user" */
@@ -654,6 +655,7 @@ static char *username_path_completion(char *ud)
654 *ud = '/'; /* restore "~user/..." */ 655 *ud = '/'; /* restore "~user/..." */
655 if (entry) 656 if (entry)
656 home = entry->pw_dir; 657 home = entry->pw_dir;
658#endif
657 } 659 }
658 if (home) { 660 if (home) {
659 ud = concat_path_file(home, ud); 661 ud = concat_path_file(home, ud);
@@ -668,15 +670,18 @@ static char *username_path_completion(char *ud)
668 */ 670 */
669static NOINLINE unsigned complete_username(const char *ud) 671static NOINLINE unsigned complete_username(const char *ud)
670{ 672{
673#if !ENABLE_PLATFORM_MINGW32
671 /* Using _r function to avoid pulling in static buffers */ 674 /* Using _r function to avoid pulling in static buffers */
672 char line_buff[256]; 675 char line_buff[256];
673 struct passwd pwd; 676 struct passwd pwd;
674 struct passwd *result; 677 struct passwd *result;
678#endif
675 unsigned userlen; 679 unsigned userlen;
676 680
677 ud++; /* skip ~ */ 681 ud++; /* skip ~ */
678 userlen = strlen(ud); 682 userlen = strlen(ud);
679 683
684#if !ENABLE_PLATFORM_MINGW32
680 setpwent(); 685 setpwent();
681 while (!getpwent_r(&pwd, line_buff, sizeof(line_buff), &result)) { 686 while (!getpwent_r(&pwd, line_buff, sizeof(line_buff), &result)) {
682 /* Null usernames should result in all users as possible completions. */ 687 /* Null usernames should result in all users as possible completions. */
@@ -685,6 +690,7 @@ static NOINLINE unsigned complete_username(const char *ud)
685 } 690 }
686 } 691 }
687 endpwent(); 692 endpwent();
693#endif
688 694
689 return 1 + userlen; 695 return 1 + userlen;
690} 696}
@@ -1824,7 +1830,11 @@ static void parse_and_put_prompt(const char *prmt_ptr)
1824 pbuf = cwd_buf; 1830 pbuf = cwd_buf;
1825 l = strlen(home_pwd_buf); 1831 l = strlen(home_pwd_buf);
1826 if (l != 0 1832 if (l != 0
1833#if !ENABLE_PLATFORM_MINGW32
1827 && strncmp(home_pwd_buf, cwd_buf, l) == 0 1834 && strncmp(home_pwd_buf, cwd_buf, l) == 0
1835#else
1836 && strncasecmp(home_pwd_buf, cwd_buf, l) == 0
1837#endif
1828 && (cwd_buf[l]=='/' || cwd_buf[l]=='\0') 1838 && (cwd_buf[l]=='/' || cwd_buf[l]=='\0')
1829 && strlen(cwd_buf + l) < PATH_MAX 1839 && strlen(cwd_buf + l) < PATH_MAX
1830 ) { 1840 ) {