From a3087ca7495e33b19b122869d17defeb9c933d19 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 8 May 2008 15:26:06 +0000 Subject: Apply post-1.10.1 patches Bump version to 1.10.2 --- libbb/lineedit.c | 19 +++++++++++-------- libbb/procps.c | 2 +- libbb/xfuncs.c | 12 ++++++------ 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index b25386bc0..b05319a9d 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -518,8 +518,8 @@ static void exe_n_cwd_tab_completion(char *command, int type) for (i = 0; i < npaths; i++) { dir = opendir(paths[i]); - if (!dir) /* Don't print an error */ - continue; + if (!dir) + continue; /* don't print an error */ while ((next = readdir(dir)) != NULL) { int len1; @@ -529,18 +529,21 @@ static void exe_n_cwd_tab_completion(char *command, int type) if (strncmp(str_found, pfind, strlen(pfind))) continue; /* not see .name without .match */ - if (*str_found == '.' && *pfind == 0) { + if (*str_found == '.' && *pfind == '\0') { if (NOT_LONE_CHAR(paths[i], '/') || str_found[1]) continue; str_found = ""; /* only "/" */ } found = concat_path_file(paths[i], str_found); - /* hmm, remover in progress? */ - if (lstat(found, &st) < 0) + /* hmm, remove in progress? */ + /* NB: stat() first so that we see is it a directory; + * but if that fails, use lstat() so that + * we still match dangling links */ + if (stat(found, &st) && lstat(found, &st)) goto cont; /* find with dirs? */ if (paths[i] != dirbuf) - strcpy(found, next->d_name); /* only name */ + strcpy(found, next->d_name); /* only name */ len1 = strlen(found); found = xrealloc(found, len1 + 2); @@ -548,7 +551,7 @@ static void exe_n_cwd_tab_completion(char *command, int type) found[len1+1] = '\0'; if (S_ISDIR(st.st_mode)) { - /* name is directory */ + /* name is a directory */ if (found[len1-1] != '/') { found[len1] = '/'; } @@ -566,7 +569,7 @@ static void exe_n_cwd_tab_completion(char *command, int type) closedir(dir); } if (paths != path1) { - free(paths[0]); /* allocated memory only in first member */ + free(paths[0]); /* allocated memory is only in first member */ free(paths); } #undef dirbuf diff --git a/libbb/procps.c b/libbb/procps.c index f67f7dcde..8946917a2 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -258,7 +258,7 @@ procps_status_t *procps_scan(procps_status_t* sp, int flags) &sp->start_time, &vsz, &rss); - if (n != 10) + if (n != 11) break; /* vsz is in bytes and we want kb */ sp->vsz = vsz >> 10; diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index ca7f94173..84b9f922b 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -704,7 +704,7 @@ int get_terminal_width_height(int fd, int *width, int *height) return ret; } -void ioctl_or_perror_and_die(int fd, int request, void *argp, const char *fmt,...) +void ioctl_or_perror_and_die(int fd, unsigned request, void *argp, const char *fmt,...) { va_list p; @@ -717,7 +717,7 @@ void ioctl_or_perror_and_die(int fd, int request, void *argp, const char *fmt,.. } } -int ioctl_or_perror(int fd, int request, void *argp, const char *fmt,...) +int ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...) { va_list p; int ret = ioctl(fd, request, argp); @@ -731,7 +731,7 @@ int ioctl_or_perror(int fd, int request, void *argp, const char *fmt,...) } #if ENABLE_IOCTL_HEX2STR_ERROR -int bb_ioctl_or_warn(int fd, int request, void *argp, const char *ioctl_name) +int bb_ioctl_or_warn(int fd, unsigned request, void *argp, const char *ioctl_name) { int ret; @@ -740,13 +740,13 @@ int bb_ioctl_or_warn(int fd, int request, void *argp, const char *ioctl_name) bb_simple_perror_msg(ioctl_name); return ret; } -void bb_xioctl(int fd, int request, void *argp, const char *ioctl_name) +void bb_xioctl(int fd, unsigned request, void *argp, const char *ioctl_name) { if (ioctl(fd, request, argp) < 0) bb_simple_perror_msg_and_die(ioctl_name); } #else -int bb_ioctl_or_warn(int fd, int request, void *argp) +int bb_ioctl_or_warn(int fd, unsigned request, void *argp) { int ret; @@ -755,7 +755,7 @@ int bb_ioctl_or_warn(int fd, int request, void *argp) bb_perror_msg("ioctl %#x failed", request); return ret; } -void bb_xioctl(int fd, int request, void *argp) +void bb_xioctl(int fd, unsigned request, void *argp) { if (ioctl(fd, request, argp) < 0) bb_perror_msg_and_die("ioctl %#x failed", request); -- cgit v1.2.3-55-g6feb