Ticket #3901 (new defect)

Opened 21 months ago

Last modified 21 months ago

Viewer in hex mode sometimes shows "-" incorrectly

Reported by: zaytsev Owned by:
Priority: major Milestone: Future Releases
Component: mcview Version: master
Keywords: Cc: egmont
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

Forwarded from Ubuntu bug tracker:

https://bugs.launchpad.net/ubuntu/+source/mc/+bug/1750239

Curious bug of "View Hex":
Depending on the name of a file (with or without extension .2)
      and on the directory(!)
the internal viewer with the hex option shows
the 1-byte ASCII character "-"
    as (incorrectly) as 3 bytes "E2 80 90"
    or (correctly) as 1 byte "2D".
This is demonstrated by screen shots taken with a 6-byte file,
but was discovered accidently with a larger file.

I could reproduce this on mc 4.8.20 with the attached sample.

Attachments

ViewHex.zip (64.4 KB) - added by zaytsev 21 months ago.

Change History

Changed 21 months ago by zaytsev

comment:1 Changed 21 months ago by egmont

Open with Shift+F3, or press F8 to switch to Raw mode and it's displayed as 2D as expected.

E2 80 90 is U+2010 Hyphen, as probably the *roff pipeline interpreting and converting the file (believing it's a manpage due to its ".2" extension).

comment:2 follow-up: ↓ 3 Changed 21 months ago by psch

This explains it, but only partially: How can this depend on the directory in which the file resides?

Furthermore, I think that "Hex" _always_ should use the "raw" file (at least by default)
-- what could be the reason to look at an interpretation in hex mode?

In general, it might be helpful and avoid confusion if mc would indicate it somehow
when interpretation is in force.

comment:3 in reply to: ↑ 2 Changed 21 months ago by egmont

Replying to psch:

This explains it, but only partially: How can this depend on the directory in which the file resides?

ext.d/text.sh seems to provide the explanation at the top of do_view_action(). If the file looks like a manual page (based on its extension I guess) then checks if it's under a "log" or "logs" directory. If so, it simply cats it, otherwise sends through manpage formatting. This is probably in order to filter out logrotate files (under /var/log and similar standard places) from being mishandled as manpages.

Furthermore, I think that "Hex" _always_ should use the "raw" file (at least by default)
-- what could be the reason to look at an interpretation in hex mode?

Independently of this particular issue, this may (or may not, up to discussion) be a valid feature request.

Or, we might think of whitelisting directories potentially containing manpages, instead of blacklisting the log ones.

In general, it might be helpful and avoid confusion if mc would indicate it somehow
when interpretation is in force.

You can see it in the bottom at "8 Raw". Not sure what could / should be a more prominent way of showing it.

(On a somewhat related note:

I loathe that user interface designers have for decades failed to figure out whether a button should show the current state, or the state it switches to. E.g. in mcview's F2, F8 and F9 in the bottom bar, I'm always getting confused as it displays what the button would take me to, it would be much more intuitive _for me_ to see the current status.

Look at youtube videos. The play/pause button shows what it would do, that is, the opposite of the current playing/paused state. Second next to that, the volume button shows whether speakers are enabled or disabled at the moment, that is, the opposite of what pressing the button does.

There are sure zillions of other similar examples...)

Note: See TracTickets for help on using tickets.