Skip to content

Commit 2417559

Browse files
committed
Fix output in sftp.
1 parent 5d600bc commit 2417559

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sftp.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,9 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
855855
(lflag & LS_SI_UNITS));
856856
#ifdef WINDOWS
857857
wchar_t* wtmp = utf8_to_utf16(lname);
858-
wprintf_s(L"%ls\n", wtmp);
858+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
859+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
860+
859861
free(tmp);
860862
#else
861863
printf("%s\n", lname);
@@ -865,7 +867,8 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
865867
else {
866868
#ifdef WINDOWS
867869
wchar_t* wtmp = utf8_to_utf16(d[n]->longname);
868-
wprintf_s(L"%ls\n", wtmp);
870+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
871+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
869872
free(wtmp);
870873
#else
871874
printf("%s\n", d[n]->longname);
@@ -875,7 +878,9 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
875878
else {
876879
#ifdef WINDOWS
877880
wchar_t* wtmp = utf8_to_utf16(fname);
878-
wprintf_s(L"%-*ls", colspace, wtmp);
881+
// TODO: Deal with the sizing wprintf_s(L"%-*s", colspace, wtmp);
882+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
883+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L" ", 1, 0, 0);
879884
free(wtmp);
880885
#else
881886
printf("%-*s", colspace, fname);
@@ -1641,7 +1646,10 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
16411646
}
16421647
break;
16431648
case I_PWD:
1644-
printf("Remote working directory: %s\n", *pwd);
1649+
printf("Remote working directory: ");
1650+
wchar_t* wtmp = utf8_to_utf16(*pwd);
1651+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
1652+
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, 0, 0);
16451653
break;
16461654
case I_LPWD:
16471655
if (!getcwd(path_buf, sizeof(path_buf))) {

0 commit comments

Comments
 (0)