Ticket #2976 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

Broken magic_mode in internal viewer

Reported by: szaszg Owned by: andrew_b
Priority: major Milestone: 4.8.8
Component: mcview Version: master
Keywords: Cc: gotar@…
Blocked By: Blocking: #2090
Branch state: merged Votes for changeset: committed-master

Description

  • create a gzipped file (e.g. gzip -c config.h >config.h.gz)
  • create a gzipped file without the gz ext. (e.g. gzip -c config.h >config.h.txt)

Reproduce:
=====================

  • open gzipped files in mcview (F3) - we see the ungzipped content
  • switch back and fort with F8 - all O.K.
  • open gzipped file with gz extension (config.h.gz) in mcview raw mode (Shift-F3) - we see the raw content
  • switch back and fort with F8 - all O.K.
  • open gzipped file without gz extension (config.h.txt) in mcview raw mode (Shift-F3) - we see the raw content
  • press F8 (=> Parsed content) - the file name in the header is disappeared, but we see the raw content
  • press F8 (=> Raw content) - the file name in the header is appeared, we see ungzipped content
  • press F8 (=> Parsed content again) - nothing happend
  • switch one panel to "quick view" mode
  • highlite any of the gzipped file - we see the raw content, and there is no filename in the viewer header
  • switch to QW "panel" and press F8 (Raw mode) - there is no filename in header and we see ungzipped content
  • press F8 (=> Parsed content again) - nothing happend

Problem:
======================
magic mode broken in mcview

If we open a file with F3 from panels, then mc use "file extension" style open (e.g. archive.sh) and Format/Raw? switching O.K.

If we open file in "Raw" mode, or use quick view, mc opens files without "file extension" helpers. Format/Raw? switching broken.

In mcview.c: mcview_load we check magic_mode and detect "compressed" files (line 375).
If magic mode on and file is "compressed" we free the current vpath and generate a new vpath with "decompress magic", but nothing else.
So, the file name disappear and we see the raw content.
After user press F8, mcview reload the file. Now filename is the "new" magic filename. mcview_load open the file with the decompress "helper" (use sfs). We see the uncompressed (parsed) content.
After user press F8, nothing happend, because original file name lost...

Solution:
======================
I attach a patch, wich fix this problem.
The patch:

  • remove the old vpath destruction
  • open the file with "uncopress magic" if magic_mode on and file "compressed"

This patch fix Ticket#2090 (CmdViewFile? Raw/Parse? switching) but not fix Ticket#2968

Attachments

mc.viewer_magic-20130309.diff (1.4 KB) - added by szaszg 11 years ago.

Change History

Changed 11 years ago by szaszg

comment:1 Changed 11 years ago by andrew_b

  • Status changed from new to accepted
  • Owner set to andrew_b
  • Votes for changeset set to andrew_b
  • Milestone changed from Future Releases to 4.8.8

Thanks for the patch! I think it will help us in #2968.

Branch: 2976_broken_magic_mode.
changeset:229a5907ae4c922987a317cdd8f92c47bbfec277

comment:2 Changed 11 years ago by andrew_b

  • Blocking 2090 added

comment:3 Changed 11 years ago by szaszg

Hmm... Sorry, but this patch not really fix Ticket#2090. Just magic mode sometimes work as open file with command. So the examples in Ticket#2090 work after this patch, but the problem still exists. The proble in Ticket#2968 is the same as in Ticket#2090. First mcviewer open the file with external helper (exec_extension_view()), but later just open with magic mode...

comment:4 Changed 11 years ago by andrew_b

  • Branch state changed from no branch to on review

comment:5 Changed 11 years ago by gotar

  • Cc gotar@… added

comment:6 Changed 11 years ago by angel_il

  • Votes for changeset changed from andrew_b to andrew_b angel_il
  • Branch state changed from on review to approved

comment:7 Changed 11 years ago by andrew_b

  • Keywords magic_mode removed
  • Status changed from accepted to testing
  • Votes for changeset changed from andrew_b angel_il to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

comment:8 Changed 11 years ago by andrew_b

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.