#endif
static const char cpmvformatcmd[] = "sed -i 's|^\\(\\(.*/\\)\\(.*\\)$\\)|#\\1\\n\\3|' %s";
-static const char cpmvrenamecmd[] = "sed 's|^\\([^#][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' %s | tr '\\n' '\\0' | xargs -0 -n2 sh -c '%s \"$0\" \"$@\" < /dev/tty'";
-static const char batchrenamecmd[] = "paste -d'\n' %s %s | sed 'N; /^\\(.*\\)\\n\\1$/!p;d' | tr '\n' '\\0' | xargs -0 -n2 mv 2>/dev/null";
-static const char archive_regex[] ="\\.(bz|bz2|gz|tar|taz|tbz|tbz2|tgz|z|zip)$";
+static const char cpmvrenamecmd[] = "sed 's|^\\([^#][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' "
+ "%s | tr '\\n' '\\0' | xargs -0 -n2 sh -c '%s \"$0\" \"$@\" "
+ "< /dev/tty'";
+static const char batchrenamecmd[] = "paste -d'\n' %s %s | sed 'N; /^\\(.*\\)\\n\\1$/!p;d' | "
+ "tr '\n' '\\0' | xargs -0 -n2 mv 2>/dev/null";
+static const char archive_regex[] = "\\.(bz|bz2|gz|tar|taz|tbz|tbz2|tgz|z|zip)$";
/* Event handling */
#ifdef LINUX_INOTIFY
static struct timespec gtimeout;
#elif defined(HAIKU_NM)
static bool haiku_nm_active = FALSE;
-static haiku_nm_h haiku_hnd = NULL;
+static haiku_nm_h haiku_hnd;
#endif
/* Function macros */
return r;
}
-static int get_cur_or_sel()
+static int get_cur_or_sel(void)
{
if (selbufpos && ndents) {
int choice = get_input(messages[MSG_CUR_SEL_OPTS]);
+
return ((choice == 'c' || choice == 's') ? choice : 0);
}
return pos;
}
-#if 0
-/* List selection from selection buffer */
-static bool listselbuf()
-{
- int fd;
- size_t pos;
- uint oldpos = selbufpos;
-
- if (!selbufpos)
- return FALSE;
-
- fd = create_tmp_file();
- if (fd == -1) {
- selbufpos = oldpos;
- return FALSE;
- }
-
- pos = seltofile(fd, NULL);
-
- close(fd);
- if (pos && pos == selbufpos)
- spawn(pager, g_tmpfpath, NULL, NULL, F_CLI);
- unlink(g_tmpfpath);
-
- selbufpos = oldpos;
- return TRUE;
-}
-#endif
-
/* List selection from selection file (another instance) */
static bool listselfile(void)
{
}
/* Finish selection procedure before an operation */
-static void endselection()
+static void endselection(void)
{
if (cfg.selmode)
cfg.selmode = 0;
static int (*filterfn)(const fltrexp_t *fltr, const char *fname) = &visible_str;
-static void clearfilter()
+static void clearfilter(void)
{
char *fltr = g_ctx[cfg.curctx].c_fltr;
ln[1] = ln[REGEX_MAX - 1];
ln[REGEX_MAX - 1] = '\0';
len = mbstowcs(wln, ln, REGEX_MAX);
- /* Go to the top, we don't know if the
- hovered file will match the filter */
+ /*
+ * Go to the top, we don't know if the
+ * hovered file will match the filter
+ */
cur = 0;
if (matches(pln) != -1)
static bool xchmod(const char *fpath, mode_t mode)
{
- (S_IXUSR & mode) ? (mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH)) : (mode |= (S_IXUSR | S_IXGRP | S_IXOTH));
+ /* (Un)set (S_IXUSR | S_IXGRP | S_IXOTH) */
+ (0100 & mode) ? (mode &= ~0111) : (mode |= 0111);
return (chmod(fpath, mode) == 0);
}
}
/* Create non-existent parents and a file or dir */
-static bool xmktree(char* path, bool dir)
+static bool xmktree(char *path, bool dir)
{
- char* p = path;
+ char *p = path;
char *slash = path;
if (!p || !*p)
// is writeable.
// Try to continue and see what happens.
// TODO: Find a more robust solution.
- if (errno == B_READ_ONLY_DEVICE) {
+ if (errno == B_READ_ONLY_DEVICE)
goto next;
- }
#endif
DPRINTF_S("mkdir1!");
DPRINTF_S(strerror(errno));
}
if (dir) {
- if(mkdir(path, 0777) == -1 && errno != EEXIST) {
+ if (mkdir(path, 0777) == -1 && errno != EEXIST) {
DPRINTF_S("mkdir2!");
DPRINTF_S(strerror(errno));
return FALSE;
}
} else {
int fd = open(path, O_CREAT, 0666);
+
if (fd == -1 && errno != EEXIST) {
DPRINTF_S("open!");
DPRINTF_S(strerror(errno));
spawn(tmp, "0", NULL, path, r);
}
-static int sum_bsizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
+static int sum_bsize(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
{
(void) fpath;
(void) ftwbuf;
return 0;
}
-static int sum_sizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
+static int sum_asize(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
{
(void) fpath;
(void) ftwbuf;
if (nftw(path, nftw_fn, open_max, FTW_MOUNT | FTW_PHYS) < 0) {
DPRINTF_S("nftw failed");
- return (cfg.apparentsz ? psb->st_size : psb->st_blocks);
+ return cfg.apparentsz ? psb->st_size : psb->st_blocks;
}
return ent_blocks;
static void move_cursor(int target, int ignore_scrolloff)
{
int delta, scrolloff, onscreen = xlines - 4;
- last_curscroll = curscroll;
+ last_curscroll = curscroll;
target = MAX(0, MIN(ndents - 1, target));
delta = target - cur;
last = cur;
case 'a': /* Apparent du */
cfg.apparentsz ^= 1;
if (cfg.apparentsz) {
- nftw_fn = &sum_sizes;
+ nftw_fn = &sum_asize;
cfg.blkorder = 1;
blk_shift = 0;
} else
if (r == 'd') {
if (!cfg.apparentsz)
cfg.blkorder ^= 1;
- nftw_fn = &sum_bsizes;
+ nftw_fn = &sum_bsize;
cfg.apparentsz = 0;
blk_shift = ffs(S_BLKSIZE) - 1;
}
}
if (sel == SEL_CHMODX)
- dents[cur].mode ^= S_IXUSR;
+ dents[cur].mode ^= 0111;
}
break;
case SEL_REDRAW: // fallthrough
switch (opt) {
case 'S':
cfg.blkorder = 1;
- nftw_fn = sum_bsizes;
+ nftw_fn = sum_bsize;
blk_shift = ffs(S_BLKSIZE) - 1; // fallthrough
case 'd':
cfg.showdetail = 1;