Re: ghostscript issues

2020-06-01 Thread Jim Garrison via Cygwin
On 6/1/2020 8:26 AM, Thomas Bodine via Cygwin wrote:
> My favorite use of ghost script is to combine PDF's. I upgraded Cygwin this 
> weekend, and ghost script fails to perform this task
> 
> I am running this:
> Cygwin Setup version 2.904 (64 bit)
> base-cygwin 3.8-1
> ghostscript 9.52-1
> ghostscript-fonts-other 6.0-1
> Windows 10 Pro version 1909 build 18363.836
> 
> When I run the script:
>  $ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite  -sOutputFile=combine.pdf  able.pdf 
> baker.pdf charly.pdf
>>
> GPL Ghostscript 9.52 (2020-03-19) 
>   
> Copyright (C) 2020 Artifex Software, Inc.  All rights reserved.   
>   
> This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
>   
> see the file COPYING for details. 
>   
> Processing pages 1 through 1. 
>   
> Page 1
>   
> Error: /rangecheck in --restore-- 
>   

Same issue here, only in my case gs is being called from OCRmyPDF.
I successfully built OCRmyPDF for Cygwin except for this issue.

Having OCRmyPDF for Cygwin would make it possible to run that tool
on Windows without having to use a VM container, which is currently
the only way to run it.

-- 
Jim Garrison j...@acm.org
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: Issue with lyx and recent dll

2020-06-01 Thread Marco Atzeri via Cygwin

On 29.05.2020 17:29, Enrico Forestieri wrote:

On Thu, May 28, 2020 at 10:01:15PM +0200, Marco Atzeri via Cygwin wrote:

On 28.05.2020 20:25, Enrico Forestieri wrote:

On Thu, May 28, 2020 at 08:09:49PM +0200, Marco Atzeri via Cygwin wrote:


after installing also another package
texlive-collection-pstricks

I was able to have an instant preview

can you check if the test 2.3.4.2-2
solve the issue also for you ?
Than I can promote it to stable


Yes, that did it! I am curious to know how you compiled it, because I see
the same strange behavior when compiling lyx from source.




--enable-qt5 PYTHON="python3"


Doh!


I also patched the source to replace python with python3 in all
the scripts.



Nevertheless, it remains a mystery why I had to revert to cygwin 3.0.7
for having instant preview working with the Qt4 version.


No idea on this.

Regards
Marco

--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: ghostscript issues

2020-06-01 Thread Marco Atzeri via Cygwin

On 01.06.2020 18:43, Ken Brown via Cygwin wrote:

On 6/1/2020 11:26 AM, Thomas Bodine via Cygwin wrote:
My favorite use of ghost script is to combine PDF's. I upgraded Cygwin 
this weekend, and ghost script fails to perform this task


I am running this:
Cygwin Setup version 2.904 (64 bit)
base-cygwin 3.8-1
ghostscript 9.52-1
ghostscript-fonts-other 6.0-1
Windows 10 Pro version 1909 build 18363.836

When I run the script:
  $ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite  -sOutputFile=combine.pdf  
able.pdf baker.pdf charly.pdf






I can confirm this.  As a workaround, downgrade ghostscript and libgs9 
to the previous version, 9.50-1, while I investigate.


Thanks for the report.

Ken
--


as alternative workaround, you can use qpdf to merge PDF files

qpdf --empty  --pages   able.pdf baker.pdf charly.pdf -- combine.pdf

Regards
Marco


--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: ghostscript issues

2020-06-01 Thread Ken Brown via Cygwin

On 6/1/2020 11:26 AM, Thomas Bodine via Cygwin wrote:

My favorite use of ghost script is to combine PDF's. I upgraded Cygwin this 
weekend, and ghost script fails to perform this task

I am running this:
Cygwin Setup version 2.904 (64 bit)
base-cygwin 3.8-1
ghostscript 9.52-1
ghostscript-fonts-other 6.0-1
Windows 10 Pro version 1909 build 18363.836

When I run the script:
  $ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite  -sOutputFile=combine.pdf  able.pdf 
baker.pdf charly.pdf



GPL Ghostscript 9.52 (2020-03-19)
Copyright (C) 2020 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
Error: /rangecheck in --restore--
Operand stack:
    --dict:8/16(L)--   --dict:38/38(ro)(L)--
Execution stack:
    %interp_exit   .runexec2   --nostringval--   restore   --nostringval--   2
%stopped_push   --nostringval--   restore   restore   false   1   %stopped_push
   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   
%op
array_pop   1978   1   3   %oparray_pop   restore   restore   2   1   1   restor
e   %for_pos_int_continue   1981   1   7   %oparray_pop   restore   restore   18
94   2   9   %oparray_pop
Dictionary stack:
    --dict:737/1123(ro)(G)--   --dict:1/20(G)--   --dict:80/200(L)--   
--dict:80/
200(L)--   --dict:135/256(ro)(G)--   --dict:318/325(ro)(G)--   --dict:33/64(L)--
    --dict:6/9(L)--   --dict:6/20(L)--
Current allocation mode is local
GPL Ghostscript 9.52: Unrecoverable error, exit code 1


I can confirm this.  As a workaround, downgrade ghostscript and libgs9 to the 
previous version, 9.50-1, while I investigate.


Thanks for the report.

Ken
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


ghostscript issues

2020-06-01 Thread Thomas Bodine via Cygwin
My favorite use of ghost script is to combine PDF's. I upgraded Cygwin this 
weekend, and ghost script fails to perform this task

I am running this:
Cygwin Setup version 2.904 (64 bit)
base-cygwin 3.8-1
ghostscript 9.52-1
ghostscript-fonts-other 6.0-1
Windows 10 Pro version 1909 build 18363.836

When I run the script:
 $ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite  -sOutputFile=combine.pdf  able.pdf 
baker.pdf charly.pdf
>
GPL Ghostscript 9.52 (2020-03-19)   
Copyright (C) 2020 Artifex Software, Inc.  All rights reserved.     
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:  
see the file COPYING for details.   
Processing pages 1 through 1.   
Page 1  
Error: /rangecheck in --restore--   
Operand stack:  
   --dict:8/16(L)--   --dict:38/38(ro)(L)--     
Execution stack:    
   %interp_exit   .runexec2   --nostringval--   restore   --nostringval--   2   
%stopped_push   --nostringval--   restore   restore   false   1   %stopped_push
  1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   %op
array_pop   1978   1   3   %oparray_pop   restore   restore   2   1   1   restor
e   %for_pos_int_continue   1981   1   7   %oparray_pop   restore   restore   18
94   2   9   %oparray_pop   
Dictionary stack:   
   --dict:737/1123(ro)(G)--   --dict:1/20(G)--   --dict:80/200(L)--   --dict:80/
200(L)--   --dict:135/256(ro)(G)--   --dict:318/325(ro)(G)--   --dict:33/64(L)--
   --dict:6/9(L)--   --dict:6/20(L)--   
Current allocation mode is local    
GPL Ghostscript 9.52: Unrecoverable error, exit code 1   


#---
# Thomas Bodine,# Father of Tawnie Rose
# Chaplain American Legion Post 76
# Skipper S/V Frimi WWP 19 #1029# Dancing to the Music Life has given me
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: Help needed with gobject-introspection

2020-06-01 Thread Jon Turney

On 01/06/2020 00:58, Ken Brown via Cygwin-apps wrote:

On 5/31/2020 4:52 PM, Jon Turney wrote:

On 29/05/2020 16:54, Jon Turney wrote:

On 27/05/2020 21:32, Ken Brown via Cygwin-apps wrote:
It looks like I've bumped into a variation of this bug.  While 
attempting to build the documentation for the latest glib2.0 
release, I got the following:


FAILED: docs/reference/gobject/gobject-decl.txt
/usr/bin/meson --internal exe --unpickle 
/home/kbrown/src/cygpackages/glib2.0/glib2.0-2.64.3-1.x86_64/src/glib-2.64.3/x86_64-pc-cygwin/meson-private/meson_exe_meson_1ed2fbe217cac49ae4affd274e0d4a729085a002.dat 

['/usr/bin/meson', '--internal', 'gtkdoc', 
'--sourcedir=/home/kbrown/src/cygpackages/glib2.0/glib2.0-2.64.3-1.x86_64/src/glib-2.64.3', 
'--builddir=/home/kbrown/src/cygpackages/glib2.0/glib2.0-2.64.3-1.x86_64/src/glib-2.64.3/x86_64-pc-cygwin', 
'--subdir=docs/reference/gobject', '--headerdirs=gobject', 
'--mainfile=gobject-docs.xml', '--modulename=gobject', '--


[...]

/docs/reference/gobject/tut_tools.xml', '--cc=gcc', '--ld=gcc', 
'--cflags=-I@BUILD_ROOT@/gobject -I../gobject -pthread 
-I@BUILD_ROOT@/. -I../. -I@BUILD_ROOT@/glib -I../glib 
-I@BUILD_ROOT@/docs/reference/gobject/. -I../docs


[...]

So @BUILD_ROOT@ didn't get replaced by the build root after pickling 
and unpickling.  Needless to say, this produced errors like:


cc1: error: @BUILD_ROOT@/glib: No such file or directory 
[-Werror=missing-include-dirs]


I can give you a precise recipe for reproducing this bug if it would 
help your debugging.


Definitely a bug.  I'll see if I can take a look at it this weekend.


https://github.com/mesonbuild/meson/pull/7229

I made a meson 0.54.2-2 test package with those patches.


Thanks!  That gets me much further in the glib build.  I still have a 
problem with the docs, but I have no reason to think it's a meson bug.  
When running 'ninja install' I get the following:


Building documentation for gio
ERROR: Error in gtkdoc helper script:

ERROR: ['/usr/bin/gtkdoc-scangobj', 
'--types=/home/kbrown/src/glib/cygbuild/docs/reference/gio/gio.types', 
'--module=gio', '--run=', '--cflags=-I/home/kbrown/src/glib/cygbuild/gio 
-I/home/kbrown/src/glib/gio -pthread 
-I/home/kbrown/src/glib/cygbuild/gmodule -I/home/kbrown/src/glib/gmodule 
-I/home/kbrown/src/glib/cygbuild/. -I/home/kbrown/src/glib/. 
-I/home/kbrown/src/glib/cygbuild/glib -I/home/kbrown/src/glib/glib 
-I/home/kbrown/src/glib/cygbuild/gobject -I/home/kbrown/src/glib/gobject 
-D_GNU_SOURCE -fno-strict-aliasing -DG_ENABLE_DEBUG 
-Wduplicated-branches -Wimplicit-fallthrough -Wmisleading-indentation 
-Wstrict-prototypes -Wunused -Wno-unused-parameter 
-Wno-bad-function-cast -Wno-cast-function-type -Wno-pedantic 
-Wno-format-zero-length -Werror=declaration-after-statement 
-Werror=format=2 -Werror=implicit-function-declaration -Werror=init-self 
-Werror=missing-include-dirs -Werror=missing-prototypes 
-Werror=pointer-arith', '--ldflags=-L/home/kbrown/src/glib/cygbuild/gio 
-Wl,-rpath,/home/kbrown/src/glib/cygbuild/gio 
-L/home/kbrown/src/glib/cygbuild/glib 
-Wl,-rpath,/home/kbrown/src/glib/cygbuild/glib 
-L/home/kbrown/src/glib/cygbuild/gobject 
-Wl,-rpath,/home/kbrown/src/glib/cygbuild/gobject 
-L/home/kbrown/src/glib/cygbuild/gmodule 
-Wl,-rpath,/home/kbrown/src/glib/cygbuild/gmodule -lgio-2.0 
-lgmodule-2.0 -lglib-2.0 -lgobject-2.0 -lz -pthread -lintl -lpcre 
-liconv -lffi', '--cc=cc', '--ld=cc', 
'--output-dir=/home/kbrown/src/glib/cygbuild/docs/reference/gio'] failed 
with status 127


I'll see what I can figure out, but as I said, it doesn't look to me 
like a meson issue.


This looks like the problem that my second patch was supposed to fix, so 
I guess I've messed up somewhere.


(gtkdoc-scangobj builds and runs a executable linked with the gio shared 
library.  meson needs to set PATH appropriately so that shared library 
can be loaded)


Re: Repeated input in PTY with SSH when a native process runs a Cygwin process that consumes input

2020-06-01 Thread Takashi Yano via Cygwin
On Sun, 31 May 2020 13:00:51 +0100
Andrew Ng  wrote:
> > The developers snapshot, in which the issue has been fixed,
> > is ready. Could you please test?
> 
> Thanks for the fast response.
> 
> I have tested the snapshot and can confirm that it fixes the issue. I
> have also applied the same fix to MSYS2 and confirmed the issue is
> fixed there too.

Thanks for testing.

> I did take a look at the code when I came across this issue and I
> noticed a few things that looked a bit odd. I noticed that the
> following functions appear to make use of rabuf () without
> consideration for raixget ():
> 
>   fhandler_termios::eat_readahead
>   fhandler_pty_master::accept_input
>   fhandler_pty_master::transfer_input_to_pcon
> 
> Also fhandler_pty_slave::eat_readahead does 'eols' processing without
> any guard on is_line_input (), which seems to differ from the code
> pattern seen elsewhere.
> 
> I don't know if these are important, but thought I should mention
> them, just in case.

Thank you for your advice. I will check if these can cause any
problem.

As for pty master, get_readahead() is not used at all, so raixget()
is always 0. So pty master code does not cause problem.

However, it is certainly dangerous. I will consider how these
should be.

-- 
Takashi Yano 
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


[ANNOUNCEMENT] cygwin 3.1.5-1

2020-06-01 Thread Corinna Vinschen
The following packages have been uploaded to the Cygwin distribution:

* cygwin-3.1.5-1
* cygwin-devel-3.1.5-1
* cygwin-doc-3.1.5-1

This is a bugfix release, including a couple of nice to have changes
on top.


What changed:
-

- Support WSL symlinks.  Create those by default now.

- FIFOs can now be opened multiple times for reading.


Bug Fixes:
--

- Fix accidental evaluation of NUL (\0) characters in xterm console output.
  Don't move cursor to the right in case of a NUL character in the console
  output stream, this is not backed by terminfo.
  Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00162.html

- Fix a segfault when starting, e.g., mintty from a bash in a console
  running xterm emulation.
  Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00197.html

- Fix TIOCINQ to always return number of inbound chars if available.
  Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00258.html

- Fix error handling in raw disk writes and allow full disk writes
  including necessary locking on floppies as well.
  Addresses: https://cygwin.com/pipermail/cygwin/2020-April/244610.html

- Fix several FIFO bugs.
  Addresses: https://sourceware.org/pipermail/cygwin/2020-March/000206.html
 https://sourceware.org/pipermail/cygwin/2020-April/244518.html

- Make sure pseudo tty doesn't hang if cygwin-console-helper.exe is
  non-functional.
  Addresses: https://cygwin.com/pipermail/cygwin-patches/2020q2/010191.html

- Fix a bug causing FIFOs to have incorrect permissions.
  Addresses: https://sourceware.org/pipermail/cygwin/2020-May/245031.html
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


cygwin 3.1.5-1

2020-06-01 Thread Corinna Vinschen
The following packages have been uploaded to the Cygwin distribution:

* cygwin-3.1.5-1
* cygwin-devel-3.1.5-1
* cygwin-doc-3.1.5-1

This is a bugfix release, including a couple of nice to have changes
on top.


What changed:
-

- Support WSL symlinks.  Create those by default now.

- FIFOs can now be opened multiple times for reading.


Bug Fixes:
--

- Fix accidental evaluation of NUL (\0) characters in xterm console output.
  Don't move cursor to the right in case of a NUL character in the console
  output stream, this is not backed by terminfo.
  Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00162.html

- Fix a segfault when starting, e.g., mintty from a bash in a console
  running xterm emulation.
  Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00197.html

- Fix TIOCINQ to always return number of inbound chars if available.
  Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00258.html

- Fix error handling in raw disk writes and allow full disk writes
  including necessary locking on floppies as well.
  Addresses: https://cygwin.com/pipermail/cygwin/2020-April/244610.html

- Fix several FIFO bugs.
  Addresses: https://sourceware.org/pipermail/cygwin/2020-March/000206.html
 https://sourceware.org/pipermail/cygwin/2020-April/244518.html

- Make sure pseudo tty doesn't hang if cygwin-console-helper.exe is
  non-functional.
  Addresses: https://cygwin.com/pipermail/cygwin-patches/2020q2/010191.html

- Fix a bug causing FIFOs to have incorrect permissions.
  Addresses: https://sourceware.org/pipermail/cygwin/2020-May/245031.html


There is no man for rsync

2020-06-01 Thread Vlado via Cygwin

Hello, rsync maintainer!

Package rsync 3.1.3+20200429+gitf7746d0-1 is offered by setup as best 
choice, but this package has no manual pages inside.
Consider to rebuild rsync 3.1.3 package, please. (nothing urgent, 
3.1.2-1 works fine for me)


Thank you.
Vlado

--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: [ANNOUNCEMENT] openssh 8.3p1-1

2020-06-01 Thread Corinna Vinschen
On Jun  1 09:45, Marco Atzeri via Cygwin wrote:
> On 27.05.2020 16:34, Corinna Vinschen wrote:
> > The following packages have been uploaded to the Cygwin distribution:
> > 
> > * openssh-8.3p1-1
> > 
> > OpenSSH is a program for logging into a remote machine and for
> > executing commands on a remote machine.  It can replace rlogin and rsh,
> > providing encrypted communication between two machines.
> > 
> 
> Hi Corinna,
> It seems you have lost most of the dependecies:

Thanks, I fixed that on sware manually.  Hopefully calm picks this
up at one point.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: [PATCH] Cygwin: pty: Fix screen distortion after using less for native apps.

2020-06-01 Thread Corinna Vinschen
On Jun  1 15:21, Takashi Yano via Cygwin-patches wrote:
> Hi Corinna,
> 
> On Mon,  1 Jun 2020 15:16:18 +0900
> Takashi Yano  wrote:
> > - If the output of non-cygwin apps is browsed using less, screen is
> >   ocasionally distorted after less exits. This frequently happens
> >   if cmd.exe is executed after less. This patch fixes the issue.
> 
> I have submitted this patch, but it's up to you to decide whether
> to include it in the cygwin 3.1.5 release.
> 
> I apologize again for the submission at the very last minute.

No worries, pushed.  I marked this as the 3.1.5 release and will
release it today.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


Re: cygwin install blurry on high dpi Windows 10

2020-06-01 Thread Sharuzzaman Ahmat Raslan via Cygwin
Hi Jon,

I tested the installer that you have provided, and the output is very sharp
and clear.

The installer functionality also works as expected.

I hope this version can be made into the official version.

Thank you.

On Sat, May 30, 2020 at 12:05 AM Jon Turney 
wrote:

> On 27/05/2020 12:41, Sharuzzaman Ahmat Raslan via Cygwin wrote:
> > Hi,
> >
> > My office laptop is Windows 10 with a high DPI display.
> >
> > I found that the installer is blurry, especially inside the window. The
> > title of the window is clear.
> >
> > Is this something that has been reported before? If nobody has reported
> it,
> > then I would like to report the issue here.
>
> Thanks for reporting this issue.
>
> This is Windows doing "dpi virtualization" (it reports 96 dpi to the
> app, and then upscales what it draws to the actual dpi)
>
> Since we (now) use standard UI elements for everything in setup, it
> should 'just' be a case of marking setup as being able to handle being
> told the real dpi.
>
> I built an updated setup with that change:
>
> https://cygwin.com/setup/setup-2.904-4-gaa071e.x86_64.exe
> https://cygwin.com/setup/setup-2.904-4-gaa071e.x86.exe
>
> Perhaps you could try that and see if it improves things for you?
>


-- 
Sharuzzaman Ahmat Raslan
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: [ANNOUNCEMENT] openssh 8.3p1-1

2020-06-01 Thread Marco Atzeri via Cygwin

On 27.05.2020 16:34, Corinna Vinschen wrote:

The following packages have been uploaded to the Cygwin distribution:

* openssh-8.3p1-1

OpenSSH is a program for logging into a remote machine and for
executing commands on a remote machine.  It can replace rlogin and rsh,
providing encrypted communication between two machines.



Hi Corinna,
It seems you have lost most of the dependecies:

version: 8.3p1-1
depends2: csih, cygrunsrv, diffutils

[prev]
version: 8.1p1-1

depends2: bash, csih, cygrunsrv, cygwin, diffutils, libcrypt2, libedit0, 
libgssa

pi_krb5_2, libkrb5_3, libssl1.1, zlib0

[prev]
version: 8.2p1-1
depends2: bash, csih, cygrunsrv, cygwin, diffutils, libcrypt2, libedit0, 
libfido2, libgssapi_krb5_2, libkrb5_3, libssl1.1, zlib0


Regards
Marco
--
Problem reports:  https://cygwin.com/problems.html
FAQ:  https://cygwin.com/faq/
Documentation:https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple


Re: [PATCH] Cygwin: pty: Fix screen distortion after using less for native apps.

2020-06-01 Thread Takashi Yano via Cygwin-patches
Hi Corinna,

On Mon,  1 Jun 2020 15:16:18 +0900
Takashi Yano  wrote:
> - If the output of non-cygwin apps is browsed using less, screen is
>   ocasionally distorted after less exits. This frequently happens
>   if cmd.exe is executed after less. This patch fixes the issue.

I have submitted this patch, but it's up to you to decide whether
to include it in the cygwin 3.1.5 release.

I apologize again for the submission at the very last minute.

-- 
Takashi Yano 


[PATCH] Cygwin: pty: Fix screen distortion after using less for native apps.

2020-06-01 Thread Takashi Yano via Cygwin-patches
- If the output of non-cygwin apps is browsed using less, screen is
  ocasionally distorted after less exits. This frequently happens
  if cmd.exe is executed after less. This patch fixes the issue.
---
 winsup/cygwin/fhandler_tty.cc | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index e434b7878..bcc7648f3 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1372,7 +1372,7 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char 
*ptr, size_t len,
  p0 = (char *) memmem (p1, nlen - (p1-buf), "\033[?1049h", 8);
  if (p0)
{
- //p0 += 8;
+ p0 += 8;
  get_ttyp ()->screen_alternated = true;
  if (get_ttyp ()->switch_to_pcon_out)
do_not_reset_switch_to_pcon = true;
@@ -1384,7 +1384,7 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char 
*ptr, size_t len,
  p1 = (char *) memmem (p0, nlen - (p0-buf), "\033[?1049l", 8);
  if (p1)
{
- p1 += 8;
+ //p1 += 8;
  get_ttyp ()->screen_alternated = false;
  do_not_reset_switch_to_pcon = false;
  memmove (p0, p1, buf+nlen - p1);
@@ -1504,7 +1504,10 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
 
   reset_switch_to_pcon ();
 
-  UINT target_code_page = get_ttyp ()->switch_to_pcon_out ?
+  bool output_to_pcon =
+get_ttyp ()->switch_to_pcon_out && !get_ttyp ()->screen_alternated;
+
+  UINT target_code_page = output_to_pcon ?
 GetConsoleOutputCP () : get_ttyp ()->term_code_page;
   ssize_t nlen;
   char *buf = convert_mb_str (target_code_page, (size_t *) ,
@@ -1513,11 +1516,11 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
   /* If not attached to this pseudo console, try to attach temporarily. */
   pid_restore = 0;
   bool fallback = false;
-  if (get_ttyp ()->switch_to_pcon_out && pcon_attached_to != get_minor ())
+  if (output_to_pcon && pcon_attached_to != get_minor ())
 if (!try_reattach_pcon ())
   fallback = true;
 
-  if (get_ttyp ()->switch_to_pcon_out && !fallback &&
+  if (output_to_pcon && !fallback &&
   (memmem (buf, nlen, "\033[6n", 4) || memmem (buf, nlen, "\033[0c", 4)))
 {
   get_ttyp ()->pcon_in_empty = false;
@@ -1530,12 +1533,12 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
   if (!(get_ttyp ()->ti.c_oflag & OPOST) ||
   !(get_ttyp ()->ti.c_oflag & ONLCR))
 flags |= DISABLE_NEWLINE_AUTO_RETURN;
-  if (get_ttyp ()->switch_to_pcon_out && !fallback)
+  if (output_to_pcon && !fallback)
 {
   GetConsoleMode (get_output_handle (), );
   SetConsoleMode (get_output_handle (), dwMode | flags);
 }
-  HANDLE to = (get_ttyp ()->switch_to_pcon_out && !fallback) ?
+  HANDLE to = (output_to_pcon && !fallback) ?
 get_output_handle () : get_output_handle_cyg ();
   acquire_output_mutex (INFINITE);
   if (!process_opost_output (to, buf, nlen, false))
@@ -1555,7 +1558,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
   release_output_mutex ();
   mb_str_free (buf);
   flags = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
-  if (get_ttyp ()->switch_to_pcon_out && !fallback)
+  if (output_to_pcon && !fallback)
 SetConsoleMode (get_output_handle (), dwMode | flags);
 
   restore_reattach_pcon ();
-- 
2.26.2