[PATCH] vi read-only mode bugfix and enhancement

Natanael Copa natanael.copa at gmail.com
Sat Jul 14 20:45:03 UTC 2007


On Fri, 2007-07-13 at 16:57 +0100, Denys Vlasenko wrote:
> Hi,
> 
> On Thursday 12 July 2007 15:35, Natanael Copa wrote:
> > Attatched is a patch that will fix a bug in vi, enhance functionality a
> > bit, reduce size and make the code a bit more readable. Testcase
> > follows.

[...]

> > Original vim shows "permission denied" but "Read-only" is better than
> > nothing.
> 
> Nice. Any chance getting "[Read failed]" (or whatever non-puzzling msg)
> so we don't need to return to this once more?

Code is messy and unreadable and even small changes tend to require
redesign. (there are 3 different way how files are read and all 3 are
handled different)

I think maybe I should start with renaming the global vars. What does
"cfn" mean? Rename it to g_current_filename or something like that and
code is easier to work with.

I will try allocate some time next week.

> > Try edit file and save as root. Old behaviour let user do this even if
> > file is write protected.
> >
> > After patch file will be marked as [Read-only]. root will need to save
> > file with :wq!
> 
> Is this feature important? 

Yes. I want this so bad so I spent some time to be able to add the
feature and reduce size at the same time to increase my chances to get
that specific feature in.

I can make it a config option if you want, but for -12 bytes i thought I
could get it for free ;-)

[...]

> Use:
> 
> #if FEATURE_VI_READONLY
> static void update_ro_status(const char *);
> #else
> static ALWAYS_INLINE void update_ro_status(const char *name) {}
> #endif
> 
> and call sites don't need USE_FEATURE_VI_READONLY(...) anymore.
> Looks better.

Ah! I wanted that but didn't know how. Thanks!

> Care to do version 2?

Will try allocate some time next week, but honestly, if im gonna touch
that code again I think I would need to start with making it more
readable.

> --
> vda




More information about the busybox mailing list