소스 검색

Print the resolved path for cwd

Avoids weird things like /etc/.. when displaying cwd.

Also no need for cwd to be on the heap.
master
sin 9 년 전
부모
커밋
a715201255
1개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. +10
    -6
      noice.c

+ 10
- 6
noice.c 파일 보기

@@ -595,8 +595,9 @@ populate(void)
void
redraw(void)
{
char cwd[PATH_MAX], cwdresolved[PATH_MAX];
size_t ncols;
int nlines, odd;
char *cwd;
int i;

nlines = MIN(LINES - 4, n);
@@ -615,11 +616,14 @@ redraw(void)
DPRINTF_S(path);

/* No text wrapping in cwd line */
cwd = xmalloc(COLS * sizeof(char));
strlcpy(cwd, path, COLS * sizeof(char));
cwd[COLS - strlen(CWD) - 1] = '\0';

printw(CWD "%s\n\n", cwd);
ncols = COLS;
if (ncols > PATH_MAX)
ncols = PATH_MAX;
strlcpy(cwd, path, ncols);
cwd[ncols - strlen(CWD) - 1] = '\0';
realpath(cwd, cwdresolved);

printw(CWD "%s\n\n", cwdresolved);

/* Print listing */
odd = ISODD(nlines);


불러오는 중...
취소
저장