[Geany-devel] Binary files - a hangup fix and some more

Алексей Антипов 1a_antipov at xxxxx
Sat Feb 6 16:37:53 UTC 2010


> Could you provide a test case to reproduce the problem?

Take some binary/malformed file (a small ZIP archive is a good example) and try opening it with the latest SVN version of Geany (that can ocassionaly happen). You'll get a hangup with 100% CPU usage.
If it is OK, try setting a "Default charset for opening files" to some 1-byte charset (e.g. ISO-8859-1).

> I don't see why we should support this. Geany is a text editor. Text
> files don't contain NULL bytes. If you want edit binary files, hex
> editors are more useful, regardless of what Notepad++ does.

They are, but sometimes I want just to see what's inside (given an unknown or broken file that I need to extract data from). Even poor old Windows notepad can handle binaries - why can't this pretty editor? 
More, some editors (Notepad++ or Midnight Commander's builtin) have a builtin Hex editor, which is sometimes useful. I'm using Geany as a primary text editor both on Windows and Linux, and I just wanted to make it more universal.

> And as you said, make such files opening isn't enough at all, there are
> certainly many places in Geany which rely on the fact files are real
> text files and I don't think this is wrong at all. Geany is a text
> editor.

Sure. Even such simple things as changing file encoding/line endings will make a mess from your binary. But if we provide a very basic capability - that would be interesting. If we use this feature, there must be a warning like "You are opening a binary file in a text editor, this can lead to an unexpected result and we strongly recommend that you make a backup".

If a plugin crashes or hangs the whole program due to some unusual sequence of symbols - that's a problem of this plugin, I think. The other question is that the plugin will give unexpected results on unusual data - but that's what the end user should be warned and care about.

I do not intend to make you use my patches (except the first one, if you can reproduce my behaviour)- just a proposal I find interesting. At least, nobody would prohibit me to use the patch myself:)

-----Original Message-----
From: Enrico Tr?ger <enrico.troeger at uvena.de>
To: geany-devel at uvena.de
Date: Sat, 6 Feb 2010 17:06:10 +0100
Subject: Re: [Geany-devel] Binary files - a hangup fix and some more

> On Sat, 06 Feb 2010 04:26:37 +0300, Алексей wrote:
> 
> Hey,
> 
> >I have been recently playing around handling binary files with Geany.
> >At least Notepad++, which is also Scintilla-based, is able to do that
> >(opens and saves binaries correctly). This feature looks very
> >promising for me, as there are sometimes files with mixed content
> >(e.g. Outlook forms, resource files or malformed e-mails).
> >
> >First, I've found a problem (seems that was partially due to my
> >charset handling patch
> >http://lists.uvena.de/geany-devel/2009-October/001480.html): when
> >opening a binary (or malformed) file Geany would hang eating 100% CPU.
> >My 1st patch is to fix that (tested for some cases, all worked... but
> >should be checked once more).
> 
> Could you provide a test case to reproduce the problem?
> 
> 
> >Then, I tried to make Geany open binaries correctly (the 2nd patch).
> >What I did was:
> > - Made encodings_convert_to_utf8 attempt to convert with "fast" flag
> > set if nothing else succeeded (if Unicode checks failed while
> > conversion itself succeeded)
> > - Made encodings_convert_to_utf8 (in fact, its duplicate) return not
> > only converted text, but also its length ('cause if a binary file
> > contains nulls it would be truncated instead)
> > - Made document_open_file_full use SCI_ADDTEXT instead of SCI_SETTEXT
> > when showing file contents. The former is able to handle NULLs while
> > the latter isn't
> >
> >Finally, I was able to view, edit and correctly save a binary file
> >with NULLs. I've attached 2 screenshots for you to see what it looks
> >like.
> 
> I don't see why we should support this. Geany is a text editor. Text
> files don't contain NULL bytes. If you want edit binary files, hex
> editors are more useful, regardless of what Notepad++ does.
> 
> And as you said, make such files opening isn't enough at all, there are
> certainly many places in Geany which rely on the fact files are real
> text files and I don't think this is wrong at all. Geany is a text
> editor.
> 
> 
> Regards,
> Enrico
> 
> -- 
> Get my GPG key from http://www.uvena.de/pub.asc
> 
> ATTACHMENT: application/pgp-signature
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
> 
> 


Лучшие предложения интернет-магазинов на Товары@Mail.Ru 
http://r.mail.ru/cln4267/torg.mail.ru/



More information about the Devel mailing list