mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Show line number only on fatal error
This commit is contained in:
parent
512b7ac6cd
commit
76d582d5cd
17
nnn.c
17
nnn.c
|
@ -159,6 +159,7 @@ disabledbg()
|
||||||
#define istopdir(path) (path[1] == '\0' && path[0] == '/')
|
#define istopdir(path) (path[1] == '\0' && path[0] == '/')
|
||||||
#define settimeout() timeout(1000)
|
#define settimeout() timeout(1000)
|
||||||
#define cleartimeout() timeout(-1)
|
#define cleartimeout() timeout(-1)
|
||||||
|
#define errexit() printerr(__LINE__)
|
||||||
|
|
||||||
#ifdef LINUX_INOTIFY
|
#ifdef LINUX_INOTIFY
|
||||||
#define EVENT_SIZE (sizeof(struct inotify_event))
|
#define EVENT_SIZE (sizeof(struct inotify_event))
|
||||||
|
@ -267,11 +268,11 @@ printmsg(char *msg)
|
||||||
|
|
||||||
/* Kill curses and display error before exiting */
|
/* Kill curses and display error before exiting */
|
||||||
static void
|
static void
|
||||||
printerr(int ret, char *prefix)
|
printerr(int linenum)
|
||||||
{
|
{
|
||||||
exitcurses();
|
exitcurses();
|
||||||
fprintf(stderr, "%s: %s\n", prefix, strerror(errno));
|
fprintf(stderr, "line %d: (%d) %s\n", linenum, errno, strerror(errno));
|
||||||
exit(ret);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print prompt on the last line */
|
/* Print prompt on the last line */
|
||||||
|
@ -1405,7 +1406,7 @@ get_output(char *buf, size_t bytes, char *file, char *arg1, char *arg2,
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
if (pipe(pipefd) == -1)
|
if (pipe(pipefd) == -1)
|
||||||
printerr(1, "pipe(2)");
|
errexit();
|
||||||
|
|
||||||
for (tmp = 0; tmp < 2; ++tmp) {
|
for (tmp = 0; tmp < 2; ++tmp) {
|
||||||
/* Get previous flags */
|
/* Get previous flags */
|
||||||
|
@ -1816,14 +1817,14 @@ dentfill(char *path, struct entry **dents,
|
||||||
if (fstatat(fd, namep, &sb, AT_SYMLINK_NOFOLLOW) == -1) {
|
if (fstatat(fd, namep, &sb, AT_SYMLINK_NOFOLLOW) == -1) {
|
||||||
if (*dents)
|
if (*dents)
|
||||||
free(*dents);
|
free(*dents);
|
||||||
printerr(1, "fstatat");
|
errexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n == total_dents) {
|
if (n == total_dents) {
|
||||||
total_dents += 64;
|
total_dents += 64;
|
||||||
*dents = realloc(*dents, total_dents * sizeof(**dents));
|
*dents = realloc(*dents, total_dents * sizeof(**dents));
|
||||||
if (*dents == NULL)
|
if (*dents == NULL)
|
||||||
printerr(1, "realloc");
|
errexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
dentp = &(*dents)[n];
|
dentp = &(*dents)[n];
|
||||||
|
@ -1863,7 +1864,7 @@ dentfill(char *path, struct entry **dents,
|
||||||
if (closedir(dirp) == -1) {
|
if (closedir(dirp) == -1) {
|
||||||
if (*dents)
|
if (*dents)
|
||||||
free(*dents);
|
free(*dents);
|
||||||
printerr(1, "closedir");
|
errexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
@ -2512,7 +2513,7 @@ nochange:
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
if (dents)
|
if (dents)
|
||||||
dentfree(dents);
|
dentfree(dents);
|
||||||
printerr(1, "lstat");
|
errexit();
|
||||||
} else {
|
} else {
|
||||||
r = show_stats(oldpath, dents[cur].name, &sb);
|
r = show_stats(oldpath, dents[cur].name, &sb);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
|
Loading…
Reference in a new issue