Permalink
Browse files

Code cleanup

  • Loading branch information...
1 parent 6ee2d8d commit a1f5ef658f2db6cf01620c628b9db65f515a24e8 James Garlick committed Feb 25, 2012
Showing with 7 additions and 23 deletions.
  1. +7 −23 src/cmd_file.c
View
@@ -118,35 +118,19 @@ void cmd_pwd (int argc, char *argv[])
void cmd_ro (int argc, char *argv[])
{
pad_t *p = e->cpad;
- int r;
- if (argc == 1)
- {
- p->flags ^= FILE_WRITE;
- }
- else
- {
+ if (argc > 1) {
if (!strcasecmp (argv[1], "on"))
- {
p->flags |= FILE_WRITE;
- }
else if (!strcasecmp (argv[1], "off"))
- {
p->flags &= ~FILE_WRITE;
- }
+ } else {
+ p->flags ^= FILE_WRITE;
}
- if (p->flags & FILE_WRITE)
- {
- if (p->filename != NULL)
- {
- r = access (p->filename, W_OK);
-
- if (r == -1 && errno != ENOENT)
- {
- p->flags &= ~FILE_WRITE;
- output_message_c (argv[0], "Permission denied");
- }
- }
+
+ if ((p->flags & FILE_WRITE) && p->filename != NULL && access(p->filename, W_OK) == -1 && errno != ENOENT) {
+ p->flags &= ~FILE_WRITE;
+ output_message_c (argv[0], "Permission denied");
}
e->redraw |= STATS;

0 comments on commit a1f5ef6

Please sign in to comment.