Skip to content

Commit e12e674

Browse files
committed
Fix screensize/handle isses.
1 parent b7d80ed commit e12e674

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed
-2.21 MB
Binary file not shown.

contrib/win32/openssh/config.h.vs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,6 @@ typedef long ssize_t;
17281728
#define HAVE_MBLEN 1
17291729

17301730
#define SSHDIR "."
1731-
#define _PATH_SFTP_SERVER "./sftp-server.exe"
1732-
#define _PATH_SSH_PROGRAM "./ssh.exe"
1731+
#define _PATH_SFTP_SERVER "sftp-server.exe"
1732+
#define _PATH_SSH_PROGRAM "ssh.exe"
17331733
#define _PATH_LS "dir"

progressmeter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ static volatile sig_atomic_t win_resized; /* for window resizing */
7878
/* units for format_size */
7979
static const char unit[] = " KMGT";
8080

81+
#ifdef WINDOWS
82+
extern int ScreenX;
83+
#endif
84+
8185
static int
8286
can_output(void)
8387
{

scp.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
850850

851851
*fdin = _open_osfhandle((intptr_t)hstdout[0],0);
852852
_setmode (*fdin, O_BINARY); // set this file handle for binary I/O
853+
w32_allocate_fd_for_handle(hstdout[0], FALSE);
853854

854855
rc = CreateOverlappedPipe( &hstdin[0], &hstdin[1], &sa, 0 ) ;
855856
/* write to this fd to get data into ssh.exe*/
@@ -865,6 +866,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
865866

866867
*fdout = _open_osfhandle((intptr_t)hstdin[1],0);
867868
_setmode (*fdout, O_BINARY); // set this file handle for binary I/O
869+
w32_allocate_fd_for_handle(hstdin[1], FALSE);
868870

869871
hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE);
870872
//hSaveStderr = GetStdHandle(STD_ERROR_HANDLE);
@@ -1067,6 +1069,10 @@ main(int argc, char **argv)
10671069
extern char *optarg;
10681070
extern int optind;
10691071

1072+
#ifdef WINDOWS
1073+
ConInit(STD_OUTPUT_HANDLE, TRUE);
1074+
#endif
1075+
10701076
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
10711077
sanitise_stdfd();
10721078

@@ -1450,7 +1456,7 @@ source(int argc, char **argv)
14501456
off_t i, statbytes;
14511457
size_t amt, nr;
14521458
int fd = -1, haderr, indx;
1453-
char *last, *name, buf[2048], encname[PATH_MAX];
1459+
char *last, *lastf, *lastr, *name, buf[2048], encname[PATH_MAX];
14541460
int len;
14551461

14561462
for (indx = 0; indx < argc; ++indx) {
@@ -1487,10 +1493,15 @@ syserr: run_err("%s: %s", name, strerror(errno));
14871493
run_err("%s: not a regular file", name);
14881494
goto next;
14891495
}
1490-
if ((last = strrchr(name, '/')) == NULL)
1496+
if ((lastf = strrchr(name, '/')) == NULL && (lastr = strrchr(name, '\\')) == NULL)
14911497
last = name;
1492-
else
1493-
++last;
1498+
else {
1499+
if (lastf)
1500+
last = lastf;
1501+
if (lastr)
1502+
last = lastr;
1503+
++last;
1504+
}
14941505
curfile = last;
14951506
if (pflag) {
14961507
if (do_times(remout, verbose_mode, &stb) < 0)
@@ -2149,7 +2160,7 @@ int start_process_io(char *exename, char **argv, char **envv,
21492160
ctr++;
21502161
}
21512162

2152-
ret = CreateProcess(
2163+
ret = CreateProcess(
21532164
exename, // given in form like "d:\\util\\cmd.exe"
21542165
cmdbuf, /* in "arg0 arg1 arg2" form command line */
21552166
NULL, /* process security */

sftp.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ typedef void EditLine;
7676

7777
#ifdef WIN32_VS
7878
#include "win32_dirent.h"
79-
extern int ScreenX;
8079
#endif
8180

8281
/* File to read commands from */
@@ -817,8 +816,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
817816
m += strlen(tmp);
818817
free(tmp);
819818
#ifdef WINDOWS
820-
ConSetScreenX();
821-
width = ScreenX ;
819+
width = ConScreenSizeX();
822820
#else
823821
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
824822
width = ws.ws_col;
@@ -941,8 +939,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
941939
}
942940

943941
#ifdef WINDOWS
944-
ConSetScreenX();
945-
width = ScreenX;
942+
width = ConScreenSizeX();
946943
#else
947944
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
948945
width = ws.ws_col;

0 commit comments

Comments
 (0)