[GRASS-dev] [GRASS GIS] #606: WinGRASS GIS.m: broken newlines in output window

#606: WinGRASS GIS.m: broken newlines in output window
----------------------------+-----------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Keywords: wingrass gis.m | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------------+-----------------------------------------------
Hi,

in wingrass gis.m output the leading newlines seem to be broken. When you
run a command the first couple of letters seem to be hidden. When you
resize the Output window by dragging on the corner (or if you run another
command) the first missing letter appears next to the scissors icon, and
the second missing letter appears at the start of the next line.

see attached screenshot.

I assume it is because gtcltk/gronsole.tcl hardcodes "\n" in a number of
places (e.g. line 231) which needs to be "\r\n" on wingrass.

maybe something like this at the beginning of gronsole.tcl?
{{{
if { $mingw == "1" } {
    set newline "\r\n"
} else {
    set newline "\n"
}
}}}

and then use $newline instead of "\n"?

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass gis.m
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

manually changing the "\n" to "\r\n" doesn't help any.

the following patch stops the first letter from ending up on the right
side of the scissors icon, but sometimes* still (temporarily) chops off
the first letter. no idea why.

[*] it follows a regular pattern: first 3 or 4 times 'Run'ning g.version
gives correct output, ~3rd or 4th time the first letter is missing until
you hit [Run] again, then the previous output is refreshed & gets its
first char back. Once you have enough output to need the scrollbar (with
the patch it) doesn't remove the leading char anymore.

When compared to the correctly working linux version, WinGrass + the patch
is the same with a single blank line between the grey command bar and the
output text for g.version. But for 'g.proj -p' the first run has 1 blank
line, the 2nd & on have two leading blank lines.

{{{
Index: lib/gtcltk/gronsole.tcl

--- lib/gtcltk/gronsole.tcl (revision 37251)
+++ lib/gtcltk/gronsole.tcl (working copy)
@@ -406,6 +406,8 @@

         if {[llength $lines] != 0} {
                 Gronsole::add_data_tag $path $ci out
+ Gronsole::output_to_gronsole $path $mark $ci [list cmd$ci
cmd$ci-out] "\n"
+ update
         }

         #output any messages from running the command
}}}

adding or removing the +update in that makes no change AFAICT.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass gis.m
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by glynn):

Replying to [comment:1 hamish]:

>
{{{
+ update
}}}
>
>
> adding or removing the +update in that makes no change AFAICT.

Don't use Tcl's "update" command unless you are able and willing to make
the function and everything which calls it re-entrant. Even then, don't
use it, as someone will eventually modify the code without considering the
re-entrancy issues, and we'll end up spending days trying to track down a
hard-to-reproduce bug. Again.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass gis.m
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by pkelly):

I've seen this issue before and suspected it was an issue with linefeeds
and carriage return characters in text files. Both g.proj and g.version
read text files and print to the screen. If the files have been created on
Windows (rather than imported from a Unix system) they will have CRLF
endings, which AFAIK still aren't handled properly everywhere.
That's just a guess though, but perhaps a line of approach that might be
worth looking into?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass gis.m
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

Replying to [comment:3 pkelly]:
> I've seen this issue before and suspected it was an issue with
> linefeeds and carriage return characters in text files. Both
> g.proj and g.version read text files and print to the screen.
> If the files have been created on Windows (rather than imported
> from a Unix system) they will have CRLF endings, which AFAIK
> still aren't handled properly everywhere.
> That's just a guess though, but perhaps a line of approach that
> might be worth looking into?

A nice guess, but no cigar.

For one thing, the problem is at the start of the file, not at a EOL or
EOF.

For another [Run]ing 'ls' ends up with "RMANENT" in the output window.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Resolution: | Keywords: wingrass gis.m
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

Replying to [comment:2 glynn]:
> Don't use Tcl's "update" command unless you are able and willing
> to make the function and everything which calls it re-entrant.
> Even then, don't use it, as someone will eventually modify the
> code without considering the re-entrancy issues, and we'll end
> up spending days trying to track down a hard-to-reproduce bug.
> Again.

ok. note that I was just cutting and pasting it from two or three lines
down in the same function where it was already used.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
----------------------------+-----------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Tcl | Version: 6.4.0 RCs
Keywords: wingrass gis.m | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------------+-----------------------------------------------

Comment(by hellik):

Replying to [ticket:606 hamish]:
> Hi,
>
> in wingrass gis.m output the leading newlines seem to be broken. When
you run a command the first couple of letters seem to be hidden. When you
resize the Output window by dragging on the corner (or if you run another
command) the first missing letter appears next to the scissors icon, and
the second missing letter appears at the start of the next line.
>
> see attached screenshot.
>
> I assume it is because gtcltk/gronsole.tcl hardcodes "\n" in a number of
places (e.g. line 231) which needs to be "\r\n" on wingrass.
>
> maybe something like this at the beginning of gronsole.tcl?
> {{{
> if { $mingw == "1" } {
> set newline "\r\n"
> } else {
> set newline "\n"
> }
> }}}
>
> and then use $newline instead of "\n"?
>
>
>
> Hamish

tested with WinGRASS-6.4.SVN-r42833-1-Setup.exe in a WinVista32-box.

it's still valid.

Helmut

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
----------------------------+-----------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Tcl/Tk | Version: 6.4.0 RCs
Keywords: wingrass gis.m | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------------+-----------------------------------------------
Changes (by hellik):

  * milestone: 6.4.0 => 6.4.2

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/606#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#606: WinGRASS GIS.m: broken newlines in output window
----------------------------+-----------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.2
Component: Tcl/Tk | Version: 6.4.0 RCs
Keywords: wingrass gis.m | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------------+-----------------------------------------------
Changes (by hamish):

  * priority: major => minor

Comment:

a report of this on debian has been submitted, but I can't reproduce it
there.

  http://bugs.debian.org/620462

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/606#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>